API Reference

Class List

pc.KeyboardEvent

The KeyboardEvent is passed into all event callbacks from the pc.Keyboard. It corresponds to a key press or release.

var 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);

Summary

Properties

elementThe element that fired the keyboard event.
eventThe original browser event which was fired.
keyThe keyCode of the key that has changed.

Details

Constructor

KeyboardEvent(keyboard, event)

Create a new KeyboardEvent

var 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);

Parameters

keyboardpc.KeyboardThe keyboard object which is firing the event.
eventpc.KeyboardEventThe original browser event that was fired.

Properties

Elementelement

The element that fired the keyboard event.

KeyboardEventevent

The original browser event which was fired.

Numberkey

The keyCode of the key that has changed. See the pc.KEY_* constants.