The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+3 votes

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.

in Engine by (695 points)

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

1 Answer

+3 votes
Best answer

you can find scancode of godot in enum KeyList at globalscope

enum KeyList

KEY_UP = 16777232 — Up Arrow Key

enter image description here

by (316 points)
selected by

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.

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

enum JoystickList:
JOYXBOXY = 3 --- XBOX controller Y button
OYANALOGLX = 0 --- Joypad Left Stick Horizontal Axis
JOYANALOGLY = 1 --- Joypad Left Stick Vertical Axis
JOYANALOGRX = 2 --- Joypad Right Stick Horizontal Axis
JOYANALOGRY = 3 --- Joypad Right Stick Vertical Axis
JOYANALOGL2 = 6 --- Joypad Left Analog Trigger
JOYANALOGR2 = 7 --- Joypad Right Analog Trigger

enter image description here

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.