@animech-public/playcanvas
Version:
PlayCanvas WebGL game engine
43 lines (42 loc) • 1.29 kB
TypeScript
/**
* The KeyboardEvent is passed into all event callbacks from the {@link Keyboard}. It corresponds
* to a key press or release.
*
* @category Input
*/
export class KeyboardEvent {
/**
* Create a new KeyboardEvent.
*
* @param {import('./keyboard.js').Keyboard} keyboard - The keyboard object which is firing the
* event.
* @param {globalThis.KeyboardEvent} event - The original browser event that was fired.
* @example
* const onKeyDown = function (e) {
* if (e.key === pc.KEY_SPACE) {
* // space key pressed
* }
* e.event.preventDefault(); // Use original browser event to prevent browser action.
* };
* app.keyboard.on("keydown", onKeyDown, this);
*/
constructor(keyboard: import("./keyboard.js").Keyboard, event: globalThis.KeyboardEvent);
/**
* The keyCode of the key that has changed. See the KEY_* constants.
*
* @type {number|null}
*/
key: number | null;
/**
* The element that fired the keyboard event.
*
* @type {Element|null}
*/
element: Element | null;
/**
* The original browser event which was fired.
*
* @type {globalThis.KeyboardEvent|null}
*/
event: globalThis.KeyboardEvent | null;
}