immersive-home/lib/events/event_key.gd

22 lines
703 B
GDScript3
Raw Normal View History

2023-11-22 02:44:07 +02:00
extends EventWithModifiers
class_name EventKey
var key: Key
var echo: bool
static func key_to_string(key: Key, caps: bool = false, apply_to: String = "") -> String:
match key:
KEY_INSERT: apply_to += DisplayServer.clipboard_get()
KEY_BACKSPACE: apply_to = apply_to.substr(0, apply_to.length() - 1)
KEY_SPACE: apply_to += " "
KEY_ASCIITILDE: apply_to += "~"
KEY_SLASH: apply_to += "/"
KEY_BACKSLASH: apply_to += "\\"
2024-01-29 13:37:25 +02:00
KEY_COLON: apply_to += ":"
KEY_COMMA: apply_to += ","
KEY_PERIOD: apply_to += "."
KEY_MINUS: apply_to += "-"
KEY_CAPSLOCK: return apply_to
_: apply_to += OS.get_keycode_string(key).to_upper() if caps else OS.get_keycode_string(key).to_lower()
return apply_to