Skip to content

Latest commit

 

History

History

keyboard-event

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

KeyboardEvent

Class for Pencil.js keyboard related events.

Examples

import { KeyboardEvent } from "pencil.js";

const eventName = "holdKey";
const key = KeyboardEvent.keys.alt;
component.fire(new KeyboardEvent(eventName, component, key));

events

Hold the list of possible events for easy access.

scene.on(KeyboardEvent.events.down, () => console.log("User pressed a key"));

keys

Hold the list of keys for easy access.

scene.on("keydown", (event) => {
    if (event.key === KeyboardEvent.keys.enter) {
        console.log("User pressed the Enter key");
    }
});