Constructor
new KeyboardEvent(keyboard, event)
Create a new KeyboardEvent
Parameters:
Name |
Type |
Description |
keyboard |
pc.Keyboard
|
The keyboard object which is firing the event. |
event |
KeyboardEvent
|
The original browser event that was fired. |
Properties:
Name |
Type |
Description |
key |
Number
|
The keyCode of the key that has changed. See the pc.KEY_* constants. |
element |
Element
|
The element that fired the keyboard event. |
event |
KeyboardEvent
|
The original browser event which was fired. |
- Source:
Example
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);