**Language / Langue :** [[fr:yaml:raccourcis|FR]] | **EN**
====== Keyboard, mouse and gamepad shortcuts ======
On Web, Desktop and in HTML exports, authors can bind keys, clicks or gamepad controls to scenario interactions. Buttons remain usable. Without author-defined bindings, a gamepad adds no automatic navigation.
===== On an action, choice or event =====
vars:
ammo: 3
actions:
- verb: fire
target: all
button: Fire
if: v_ammo_v > 0
do: ammo - 1
shortcut:
keys: [Space, f]
mouse: left
gamepad: [A, RT]
show-shortcut: true
''shortcut: [Space, f]'' is enough for keyboard-only bindings. ''show-shortcut'' adds a hint to the button; it is hidden by default. An event with a shortcut needs an explicit ''id''. An event bound to a shortcut is manual: it waits for input instead of firing automatically. Its conditions, state and usage limits still apply.
===== Commands and referenced events =====
shortcuts:
- keys: [i]
gamepad: B
command: inventory
rooms:
- id: question
shortcuts:
- keys: [Ctrl+Enter]
event: question_hint
events:
- id: question_hint
text: The code is 42.
These lists can be declared at the root or in a room. Each entry targets either a ''command'', with optional arguments, or an existing ''event''. They add no buttons. Available commands depend on the support being used.
===== Controls =====
^ Input ^ Examples ^
| Keys | ''z'', ''ArrowUp'', ''Space'', ''Enter'', ''Escape'', ''F1'' to ''F24'' |
| Combinations | ''Ctrl+1'', ''Shift+z'', ''Alt+Enter'', ''Meta+Enter'' |
| Physical codes | ''KeyW'', ''Digit1'', ''Numpad1'' |
| Click on the game background | ''left'', ''right'', ''middle'' |
| Gamepad buttons | ''A'', ''B'', ''X'', ''Y'', ''LB'', ''RB'', ''LT'', ''RT'', ''LS'', ''RS'', ''Back'', ''Start'', ''Home'' |
| D-pad and sticks | ''DPadUp'', ''LeftStickLeft'', ''RightStickDown'' and the other directions |
| Raw controls | ''Button0'' to ''Button63'', ''Axis0+'' / ''Axis0-'' to ''Axis15+'' / ''Axis15-'' |
Quote digits in YAML: ''keys: ["1"]''. Letters follow the keyboard layout; physical codes follow the position. Clicks on buttons, links and interactive images keep their usual role; touch does not become a mouse shortcut.
Gamepad names follow the browser's standard mapping: A at the bottom, B on the right, X on the left, Y at the top. ''Cross/Circle/Square/Triangle'' and ''L1/R1/L2/R2/L3/R3'' are accepted. Controller labels may differ; raw numbers depend on the hardware.
===== During play =====
* One press triggers one action. Holding a key or direction does not repeat turns; return to neutral to act again.
* Shortcuts are ignored while typing or while a dialogue, menu or action is active. Ignored presses are not queued.
* Local bindings take priority over global ones. Within one scope: actions, events, choices, then list commands, in declaration order.
* An unavailable binding reserves its key. Hidden or greyed-out choices do not become accessible through shortcuts.
* Explicit shortcuts take priority over native deck directions or keyboard triggers. The linter reports collisions.
Gamepads need the browser's Gamepad API, generally over HTTPS or localhost. A first press may be needed for detection.
===== In the editor =====
Actions, choices and events have shortcut fields. Command lists are under **Globals > Interface** and in the room interface settings. **Detect a button** captures a new gamepad press; release held controls first. Clicking the capture button again cancels it.
Mini Doom provides an example: arrows/ZQSD or D-pad/stick to move, Space/F/left click or A/RT to fire. The game rules are written in the scenario.