system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
Timofffee |
|
Old Version |
Published before Godot 3 was released. |
Good time of day. I have a serious question. How to get the symbol when the key is pressed, but it does not use a LineEdit and other nodes?
Input.is_key_pressed(key_tag)?
rustyStriker | 2017-07-29 12:41
system
4
|
|
|
|
Reply From: |
Dr_TwiSteD |
You can have it done by reading the input and converting the scancodes using the built-in KEY_* constants of the global scope.
Simple code snippet would look like this:
func _ready():
set_process_input(true)
func _input(event):
if event.type == InputEvent.KEY and event.is_pressed():
print('pressed: ' + str(event.unicode))
if event.scancode == KEY_A:
print('AHA!')
As far as I know there’s no direct way to convert scancodes to string, so you can create a dictionary like {scancode: ‘string’} to convert symbols.
Was such a thought, but what about the signs? If letters and numbers - it’s just, the characters each keyboard is different.
Timofffee | 2017-07-31 07:31
Okay!
OS.get_scancode_string(event.unicode)
I found a solution to a slightly different line.
Thanks for the help. It remains only to convert “Percent” to"%", etc.
Timofffee | 2017-07-31 07:40