[title: "KeyboardListener Class"] ← Back to index

Keyboard input listener

[heading: "Description"]

KeyboardListener forwards the browser keyboard events captured by Phaser into onDown and onUp Phaser signals that carry the key code and the original event.

[heading: "Key Features"] [list] * Bridges Phaser's global keyboard callbacks to Phaser signals [/list] [heading: "Constructor"] [table header] [ Parameter | Type | Description ] [ game | Phaser.Game | Phaser game instance ] [/table] [heading: "Properties"] [table header] [ Property | Type | Description ] [ game | Phaser.Game | Phaser game instance being listened to ] [ onDown | Phaser.Signal | Dispatched with key code and event when a key is pressed ] [ onUp | Phaser.Signal | Dispatched with key code and event when a key is released ] [/table] [heading: "Example Usage (Modding)"] [codeblock javascript] // Modding usage example const listener = new KeyboardListener(game); listener.onDown.add((keyCode, event) => { console.log(`Key down: ${keyCode}`); }); [/codeblock] [footer: "© Retora 2026"]