pencil.js
Version:
Nice modular interactive 2D drawing library.
37 lines (23 loc) • 619 B
Markdown
Class for Pencil.js keyboard related events.
```js
import { KeyboardEvent } from "pencil.js";
const eventName = "holdKey";
const key = KeyboardEvent.keys.alt;
component.fire(new KeyboardEvent(eventName, component, key));
```
Hold the list of possible events for easy access.
```js
scene.on(KeyboardEvent.events.down, () => console.log("User pressed a key"));
```
Hold the list of keys for easy access.
```js
scene.on("keydown", (event) => {
if (event.key === KeyboardEvent.keys.enter) {
console.log("User pressed the Enter key");
}
});
```