How to get the 'event' scancode?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JulioYagami

Godot 2.0 had something like this:

func _input(event):
    if event.scancode = some_code:
        #do something

But as for 3.0 I do not know.

Here is a list I’ve found in internet:

http://www.ee.bgu.ac.il/~microlab/MicroLab/Labs/ScanCodes.htm

I think it’s like keycodes:

https://keycode.info/

You can go to Project->Project Settings and configure the Input Map to use the keys like this:

if Input.is_action_pressed("ui_accept"):
    # do something

Alex Pires | 2019-02-24 17:40

:bust_in_silhouette: Reply From: TyTYctA

you can find scancode of godot in enum KeyList at globalscope

enum KeyList

KEY_UP = 16777232 — Up Arrow Key

enter image description here

It only works if the key I’m pressing is a InputEventKey. And as for other inputs types?. For example, I want to set a action for the joystick button the player presses.

JulioYagami | 2019-02-25 13:05

If you want to use Joypad, you can see InputEventJoypadButton, InputEventJoypadMotion and enum JoystickList in globalscope

enum JoystickList:
JOY_XBOX_Y = 3 — XBOX controller Y button
OY_ANALOG_LX = 0 — Joypad Left Stick Horizontal Axis
JOY_ANALOG_LY = 1 — Joypad Left Stick Vertical Axis
JOY_ANALOG_RX = 2 — Joypad Right Stick Horizontal Axis
JOY_ANALOG_RY = 3 — Joypad Right Stick Vertical Axis
JOY_ANALOG_L2 = 6 — Joypad Left Analog Trigger
JOY_ANALOG_R2 = 7 — Joypad Right Analog Trigger

you should see Input Remapping in Godot tutorial for understand more about input event in godot

TyTYctA | 2019-02-26 03:32