Skip to main content

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​

SourceUse Case
KeyboardDesktop controls
MouseDesktop pointing
TouchMobile/tablet
GamepadController 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);
}
}