Input
Keyboard, gamepad and touch: actions and bindings, reacting to them, moving through windows, the pause menu and on-screen prompts.
Actions and keys
Keyboard, gamepad (incl. Steam Deck) and touch all produce the same actions. Content reacts to actions, never to raw keys.
// src/content/config/input.ts
export default defineInput({
actions: {
up: { keys: ['ArrowUp', 'KeyW'], buttons: [GP.DpadUp], stick: 'up' },
confirm: { keys: ['Enter', 'Space', 'KeyF'], buttons: [GP.A] },
cancel: { keys: ['Escape', 'Backspace'], buttons: [GP.B] },
menu: { keys: ['Escape'], buttons: [GP.Start] }, // Escape is cancel too: see Pause menu
inventory: { keys: ['KeyE'], buttons: [GP.X], vnMode: false }, // not in VN-only mode
// padLocked / padResetInMenus: see Touch, gamepads and prompts below
map_marker: { keys: ['KeyM'], buttons: [GP.LeftStick] }, // a new action: now typed everywhere
},
backButton: ['cancel', 'menu'], // Android's Back: the first that does something
touchButtons: [
{ action: 'confirm', label: 'A', layers: ['map'] }, // only over the map
{ action: 'cancel', label: 'B', layers: ['map'] },
{ action: 'inventory', label: 'Bag', layers: ['map'] },
// place: 'top-right' pins a button to the top right corner instead
],
})
- Keys are
KeyboardEvent.codenames (KeyW,Space,ArrowUp): the position on the keyboard, so WASD works on any layout. - Required actions:
up,down,left,right,confirm,cancel,menu. The engine also reacts toinventory,skip,back,auto,log,hide(scenes),tabPrev/tabNext(tabs, title switcher, pages),quickSave,quickLoad,screenshotandfullscreen. Leaving one out of the file is allowed: it then has no key or button. vnMode: false: the action is off in VN-only mode (config/mode.ts): it never fires and isn't listed in Settings → Controls.src/content/config/input.test.tschecks that every action has a key and a controller button (a short keyboard-only list), and that no key or button does two things unless listed as on purpose. Change its lists when you change the bindings on purpose.- Gamepad buttons:
GP.A,B,X,Y,LB,RB,LT,RT,Back,Start,LeftStick,RightStickand the fourDpad…(Xbox names; other pads use the same positions). - A new action needs a display name in
windows/settings/Controls.tsx(a type error reminds you).
Default controls
| Action | Keyboard | Controller |
|---|---|---|
| Move / choose | Arrows, WASD | D-pad, left stick |
| Confirm / cancel | Enter, Space, F / Escape, Backspace | A / B (Nintendo: see Confirm with) |
| Pause menu | Escape | Start |
| Inventory (not in VN-only mode) | E | X |
| Skip (hold) / back a line | Ctrl / Page Up | RT / LB |
| Auto-play / log / hide the text box | T / L / H | RB / View / Y |
| Previous / next tab | Q / R | LB / RB |
| Quick save / quick load | F5 / F9 | none (players can add one) |
| Screenshot / fullscreen | F8 / F11 | (the console's own screenshot button) |
Reacting to actions
// React (any screen): active on the screen the component belongs to
useAction('map_marker', () => placeMarker())
useAction('cancel', () => { if (!submenu) return false; closeSubmenu() }) // false = pass it on
useAction('inventory', toggle, { layers: ['map', 'windows'] }) // also while windows are open
const skipping = useHeld('skip') // held down right now
// Game loops and scripts
game.input.isDown('confirm')
game.input.move('map') // { x, y } from arrows / stick / joystick, -1..1
- Only the top screen gets actions (title, windows, minigame, event, map, from the top). Inside windows, only the front window's handlers.
- The newest handler wins; returning
falsepasses the action to the next one, then to the engine default (cancel closes, arrows move focus). - Keys the game handles don't reach focused MUI widgets (so a slider doesn't also move); others pass through (typing in a text field).
- Directions repeat when held on a gamepad or touch (after 400 ms, then every 120 ms).
Navigation in windows
- When a window opens it focuses its first control (not on touch). Up/down/left/right move between buttons, switches and sliders in the window.
- A slider is one target: its whole track counts, so pressing down from a button reaches the slider below it.
- An open dropdown (MUI Select, Menu) takes pad input: up/down move through its options, confirm picks, cancel (Esc, pad B) closes just the dropdown. While it is open no other game action fires (Esc does not open the menu).
- Custom boxes can name their navigation box with
data-nav-rect, e.g.<div data-nav-rect>around a group of controls. - To send a direction somewhere on purpose, put
data-nav-up/-down/-left/-rightwith a CSS selector on the control or on a box around it:<Box data-nav-down="[data-mute]">. It wins over the position-based pick when it matches a visible control. Use it for a button left or right of a slider (left/right there only change the value), as in Settings → Voices.
Pause menu
The Menu action (Escape, Start on a pad, or the ☰ button) opens the pause menu, the window windows/menu: a grid of buttons (arrows or d-pad move between them) that reaches every window: Inventory, Quests, Party, Journal, Save, Load, Settings, Log (during a scene), I'm stuck (on a map), Title and Quit (desktop app). Escape also closes the front window (it is cancel too). One key or pad button press goes to one action, the first one that takes it, so Escape on a window closes only that window, and B that closes a window does not also hide the text box under it. The Menu button also closes the front window (unless a handler takes it first), so the pad button that opened the menu backs out of it one window at a time, as Escape does. Inventory also has its own key, E (X on a pad), next to WASD; confirm is F, Enter or Space. Tabs in Journal, Extras and Settings switch with Q / R (LB / RB on a pad). Those are the actions tabPrev and tabNext; any window with tabs can use useTabs(setTab, [...]).
Clicking outside a window
A click or tap outside every window closes the top one (one at a time) and does nothing else: while a window is open, nothing under it can be clicked (the map, a scene and its toolbar, the title menu). Clicking inside another window brings it to the front instead. Windows marked closable: false stay open, and still block the click. The ☰ button stays usable.
Touch, gamepads and prompts
- Touch: a joystick plus
touchButtonsappear on touch screens while the map or a scene is on top. Buttons sit bottom right (the first is largest);place: 'top-right'pins one to the corner;layers: ['map']or['event']limits where it shows. In scenes a tap continues, so A/B are only needed on the map. A tap only continues a line if it started on the scene while nothing was above it: taps on a window, on the ☰ button, or that close a window never move the dialogue on. Where the joystick and buttons sit, their sizes and symbols:src/content/ui/TouchControls.tsx. - The ☰ pause menu button is its own file,
src/content/ui/MenuButton.tsx(restyle it there). It shows on every device (PC, Steam Deck, phone, browser) during play on every layer (map, scenes, minigames, over windows), never on the title, and opens or closes themenuwindow. - The game never acts like a web page: text can't be selected (except in inputs), taps don't flash, and the page can't be zoomed (pinch, double-tap, Ctrl + wheel, Ctrl + plus/minus) in the browser, Electron or Android. The browser's right-click / long-press menu (save image, view source...) never opens, but the game's own
onContextMenuhandlers still run. An element that needs its own touch gestures setstouchAction: 'none'. - Gamepads are detected by type (Xbox, PlayStation, Nintendo, Steam Deck) so prompts show the right button names. Nintendo controllers confirm with the right face button (A): Settings → Controls Confirm with (Automatic, Bottom button, Right button) swaps the two buttons, and every prompt follows. The names and face-button colours per controller, and the names of keys (Esc, ↑, Ctrl…), are in
src/content/look/glyphs.ts; a button it leaves out shows as#n, a key by its code. - The mouse wheel in scenes (down = next line, up = the log): what it does and how small a movement is ignored, how fast steps come:
wheelinsrc/content/scenes.ts. - The mouse cursor hides at once while a gamepad is in use (never for touch) and comes back as soon as the mouse moves. Separately, Settings → General → Hide idle mouse (
settings.cursorAutoHide: Never, 10 s, 5 s) hides it after the mouse sits still that long; the choices and default arecursorAutoHide/defaultCursorAutoHideinsrc/content/config/screen.ts(seconds, 0 = never). - Players change keys and buttons in Settings → Controls (saved per device; the tab is hidden on touch). In code:
game.input.setBinding,resetBindings,capture(). - Settings → Controls is a picture of the device in use:
windows/settings/Keyboard.tsx(a key table, drawn) orController.tsx(the artcontroller.svgplus a table of where each button sits on it). Every key / button on it is a button: press one, and the panel under the picture lists every action; turn on the ones that key / button should do (a key may do two, like Escape = cancel + menu). Pointing at an action lights its keys / buttons. An action left with none shows as "Not set". Confirm with only shows while a controller is in use. Swap the art or move the buttons in those files. - Controller safety, in
config/input.ts:padLocked: true(the menu) = its controller button can't be changed or taken by another action, so Settings can always be reached.padResetInMenus: true(moving, confirm, cancel) = while a window inmenuWindows(pause menu, Settings, and any dialog over them) is open, these use the buttons from the file, whatever the player set; elsewhere the player's own. So no rebinding can lock a controller player out.