Input Overview
GameByte provides a unified input system for all platforms.
🎮Whack-a-Mole - Touch, Click & Keyboard Input
Loading demo...
🎮Keyboard Input Demo
Loading demo...
🎮Touch Input - Tap, Swipe, Pinch & Long Press
Loading demo...
Input Sources​
| Source | Use Case |
|---|---|
| Keyboard | Desktop controls |
| Mouse | Desktop pointing |
| Touch | Mobile/tablet |
| Gamepad | Controller support |
Quick Start​
import { Input } from '@gamebyte/framework';
const input = game.make('input');
// Keyboard
input.keyboard.on('KeyW', (pressed) => {
if (pressed) moveForward();
});
// Touch
input.touch.on('tap', (event) => {
handleTap(event.x, event.y);
});
// Gamepad
input.gamepad.on('button-a', () => {
jump();
});
Polling vs Events​
// Event-based (recommended)
input.keyboard.on('Space', (pressed) => {
if (pressed) jump();
});
// Polling (for continuous actions)
function update(deltaTime: number) {
if (input.keyboard.isPressed('KeyA')) {
moveLeft(deltaTime);
}
}