You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/classes/Shortcut.xml
+16-2Lines changed: 16 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,22 @@
4
4
A shortcut for binding input.
5
5
</brief_description>
6
6
<description>
7
-
Shortcuts are commonly used for interacting with a [Control] element from an [InputEvent] (also known as hotkeys).
8
-
One shortcut can contain multiple [InputEvent]s, allowing the possibility of triggering one action with multiple different inputs.
7
+
Shortcuts (also known as hotkeys) are containers of [InputEvent] resources. They are commonly used to interact with a [Control] element from an [InputEvent].
8
+
One shortcut can contain multiple [InputEvent] resources, making it possible to trigger one action with multiple different inputs.
9
+
[b]Example:[/b] Capture the [kbd]Ctrl + S[/kbd] shortcut using a [Shortcut] resource:
10
+
[codeblock]
11
+
var save_shortcut = Shortcut.new()
12
+
func _ready() -> void:
13
+
var key_event = InputEventKey.new()
14
+
key_event.keycode = KEY_S
15
+
key_event.ctrl_pressed = true
16
+
key_event.command_or_control_autoremap = true # Swaps ctrl for Command on Mac.
17
+
save_shortcut.set_events([key_event])
18
+
19
+
func _input(event) -> void:
20
+
if save_shortcut.matches_event(event) and event.is_pressed() and not event.is_echo():
0 commit comments