Packages
Search packages... ⌘K
SvelteKit Package
engine-input
Input manager — unified keyboard, mouse, and touch input handling for games
SvelteKit Ready SI
Input Handling typescript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import { InputManager, Keyboard } from '@sbx/engine-input';
const input = new InputManager();
input.bind(canvas);
// Configure key bindings
input.keyboard.map({
'ArrowLeft': 'move-left',
'ArrowRight': 'move-right',
'Space': 'jump',
});
// In game loop
function update() {
if (input.keyboard.isDown('move-left')) player.x -= speed;
if (input.keyboard.justPressed('jump')) player.jump();
const mouse = input.mouse.position; // { x, y }
}About
Cross-platform input abstraction layer. Normalizes keyboard events into action bindings, tracks mouse position and button state, and handles touch gestures (tap, swipe, pinch). Supports configurable key mappings, input buffering for frame-perfect timing, and simultaneous multi-input tracking.
Public API
| Name | Kind | Signature |
|---|---|---|
| InputManager | type | class InputManager — bind(element), update(), getState() |
| Keyboard | type | class Keyboard — isDown(key), justPressed(key), bindings |
| Mouse | type | class Mouse — position, buttons, delta, wheel |
| Touch | type | class Touch — touches, gesture, pinchScale |
Related Packages
game-svelte SvelteKit Ready
Svelte game framework — Game component shell with lifecycle, loop, and renderer integration
svelte-5gamepixijscanvasgame-loop
1 exports 2 deps
engine-renderer SvelteKit Ready
Rendering engine — PixiJS-based game renderer with grid, backgrounds, and visual effects
game-enginerenderingpixijswebglgrideffectsparticles
4 exports 2 deps
Source
@sbx/engine-input
game-engineinputkeyboardmousetouchgestures