Skip to content

five-on-it / apps/client/src/renderer/keyboard

apps/client/src/renderer/keyboard ​

Keyboard state from DOM events: which codes are held, plus one-shot presses (a key that fires once per press, read and cleared by the game loop). The game loop samples the held keys once per tick; a key tapped and released between two samples still shows up in the next one, so no tap is ever lost to the 60 Hz tick. Presses are counted, so two quick presses between two ticks are both delivered, and the gap between the last two presses of a key is kept for double taps. A key pressed in one of the overlay's fields or controls (typing in the server field, a focused button) is the overlay's, not the game's: only presses on the canvas or on nothing in particular (the page's body) count, and of those not the ones a field of the in-game UI drawn on the canvas took (a keypad's code: the claimed test); releases always do, so a key held across a click into a field never sticks. Keys go through the player's bindings (setTranslate, ui/bindings.ts): a key bound to an action reaches the game as that action's default key, and a default key bound to nothing does not reach it at all.

Interfaces ​

Functions ​