Is there a list of Input keys?

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

So, I want to check for keys pressed. Particullary space key.
How do I do it in _process ?
the only way I found so far is to do this:

func _input(event):
    print('Event')
    print(event.get_class() == 'InputEventKey') # To check if that's a key press event
    print(event.as_text() == 'Space') # to check if that's a space key

Which doesn’t work for me. Is there a list of String key codes I can use for :

Input.is_action_just_pressed( ??? )

‘space’ and “Space” not working.

Thank you!

1 Like
:bust_in_silhouette: Reply From: hilfazer
if event is InputEventKey:
	if event.scancode == KEY_SPACE:
		pass

List is in the @GlobalScope

under enum KeyList

You can’t use them in is_action_just_pressed(). Actions and keys are different. Keys can be assigned to actions so they trigger them. Check “Project Settings / Input Map”.

Gotcha, thank you

guba-odudkin | 2018-08-26 12:37

:bust_in_silhouette: Reply From: ruruarchy

you could also use this to view the name of pressed key :slight_smile:

  func _input(ev):
    	if ev is InputEventKey :
    		(print(OS.get_scancode_string(ev.scancode)))

it will print twice in pressing a key once, 1 for pressed 1 for released

ruruarchy | 2019-06-25 09:16