Skip to content

Commit c9025c2

Browse files
Update Shortcut class reference
1 parent 64e015c commit c9025c2

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

doc/classes/Shortcut.xml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@
44
A shortcut for binding input.
55
</brief_description>
66
<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() -&gt; 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) -&gt; void:
20+
if save_shortcut.matches_event(event) and event.is_pressed() and not event.is_echo():
21+
print("Save shortcut pressed!")
22+
[/codeblock]
923
</description>
1024
<tutorials>
1125
</tutorials>

0 commit comments

Comments
 (0)