@yagejs/input
v0.1.0
Published
Keyboard, mouse, gamepad, and touch handling for YAGE
Maintainers
Readme
@yagejs/input
Keyboard, mouse, gamepad, and touch handling for the YAGE 2D game engine.
Install
npm install @yagejs/inputUsage
import { Engine } from "@yagejs/core";
import { InputPlugin, InputManagerKey } from "@yagejs/input";
const engine = new Engine();
engine.use(new InputPlugin({
actions: {
jump: ["Space", "KeyW"],
left: ["ArrowLeft", "KeyA"],
right: ["ArrowRight", "KeyD"],
},
}));Read input inside a component:
class PlayerController extends Component {
private readonly input = this.service(InputManagerKey);
update(dt: number): void {
if (this.input.isActionDown("jump")) {
// jump
}
}
}What's in the box
- InputPlugin / InputManager - unified keyboard, mouse, gamepad, touch
- Action maps - bind named actions to multiple keys
- Runtime rebinding - with conflict policies
- Pointer events - world-space mouse/touch with camera awareness
Docs
Full documentation at yage.dev.
License
MIT
