KeyboardHandler
A modern keyboard handler that manages keyboard events using a stateful pattern. It supports separate handlers for key down, key up, and continuous key pressed events. The handler calculates a movement vector based on currently pressed keys.
Creates an instance of KeyboardHandler.
The HTMLCanvasElement to attach keyboard events to.
Callback invoked whenever the calculated movement vector is updated.
Register handler to related browser events Prevents double registrations
Registers a handler for a key down event.
The event.code of the key.
Callback invoked on key down.
Registers a handler for a key up event.
Callback invoked on key up.
Resets the handler state by clearing all pressed keys and recalculating movement.
Unregister handler from related browser events Prevents double unregistration
KeyboardHandler
A modern keyboard handler that manages keyboard events using a stateful pattern. It supports separate handlers for key down, key up, and continuous key pressed events. The handler calculates a movement vector based on currently pressed keys.