@nanoforge-dev/input
v1.0.0
Published
NanoForge Engine - Input
Readme
About
@nanoforge-dev/input is an input manager for handling keyboard and mouse events.
Installation
Node.js 24.11.0 or newer is required.
npm install @nanoforge-dev/input
yarn add @nanoforge-dev/input
pnpm add @nanoforge-dev/input
bun add @nanoforge-dev/inputExample usage
Initialize the library in your main file
import { type IRunClientOptions } from "@nanoforge-dev/common";
import { NanoforgeFactory } from "@nanoforge-dev/core";
import { InputLibrary } from "@nanoforge-dev/input";
export async function main(options: IRunClientOptions) {
const app = NanoforgeFactory.createClient();
const input = new InputLibrary();
app.useInput(input);
await app.init(options);
await app.run();
}Use to check for key presses
export function mySystem(registry: Registry, ctx: Context) {
const input = ctx.libs.getInput<InputLibrary>();
const isArrowUpPressed = input.isKeyPressed(InputEnum.ArrowUp);
// Do something with the input
}Links
Contributing
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
documentation.
See the contribution guide if you'd like to submit a PR.
Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in discussions.
