FGGE  v0.7
Fabiogiopla HTML5 Game Engine
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
GameEngine.Keyboard.KeyboardEvent Class Reference

Describes a Keyboard event. More...

Public Member Functions

var getKeyNumber ()
 Get key number.
 
var getEventType ()
 Detect if a key is pressed or released.
 

Public Attributes

const EVENT_PRESS
 Key was pressed.
 
const EVENT_RELEASE
 Key was released.
 
const KEY_BACKSPACE
 
const KEY_TAB
 
const KEY_ENTER
 
const KEY_SHIFT
 
const KEY_CTRL
 
const KEY_ALT
 
const KEY_PAUSE
 
const KEY_ESCAPE
 
const KEY_SPACE
 
const KEY_PAGEUP
 
const KEY_PAGEDOWN
 
const KEY_END
 
const KEY_HOME
 
const KEY_LEFT
 
const KEY_UP
 
const KEY_RIGHT
 
const KEY_DOWN
 
const KEY_PRINT
 
const KEY_INSERT
 
const KEY_DELETE
 
const KEY_0
 
const KEY_1
 
const KEY_2
 
const KEY_3
 
const KEY_4
 
const KEY_5
 
const KEY_6
 
const KEY_7
 
const KEY_8
 
const KEY_9
 
const KEY_A
 
const KEY_B
 
const KEY_C
 
const KEY_D
 
const KEY_E
 
const KEY_F
 
const KEY_G
 
const KEY_H
 
const KEY_I
 
const KEY_J
 
const KEY_K
 
const KEY_L
 
const KEY_M
 
const KEY_N
 
const KEY_O
 
const KEY_P
 
const KEY_Q
 
const KEY_R
 
const KEY_S
 
const KEY_T
 
const KEY_U
 
const KEY_V
 
const KEY_W
 
const KEY_X
 
const KEY_Y
 
const KEY_Z
 
const KEY_NUMPAD0
 
const KEY_NUMPAD1
 
const KEY_NUMPAD2
 
const KEY_NUMPAD3
 
const KEY_NUMPAD4
 
const KEY_NUMPAD5
 
const KEY_NUMPAD6
 
const KEY_NUMPAD7
 
const KEY_NUMPAD8
 
const KEY_NUMPAD9
 
const KEY_F1
 
const KEY_F2
 
const KEY_F3
 
const KEY_F4
 
const KEY_F5
 
const KEY_F6
 
const KEY_F7
 
const KEY_F8
 
const KEY_F9
 
const KEY_F10
 
const KEY_F11
 
const KEY_F12
 
const KEY_NUMLOCK
 
const KEY_SCROLLLOCK
 

Detailed Description

Describes a Keyboard event.

Describes a Keyboard event like key pressing or releasing.

Member Function Documentation

var GameEngine.Keyboard.KeyboardEvent.getEventType ( )

Detect if a key is pressed or released.

May return EVENT_PRESS or EVENT_RELEASE.

// Print ID of intercepted keys.
function keyboardListener(event) {
var pressed = (event.getEventType() == GameEngine.Keyboard.KeyboardEvent.EVENT_PRESS);
alert("Key '"+event.getKeyNumber()+"' has been "+(pressed?"pressed":"released")+".");
}
GameEngine.Keyboard.addKeyboardListener(keyboardListener);
Returns
Key status, can be EVENT_PRESS or EVENT_RELEASE.
var GameEngine.Keyboard.KeyboardEvent.getKeyNumber ( )

Get key number.

Returns the number of the key intercepted with the event.

// Print ID of intercepted keys.
function keyboardListener(event) {
var pressed = (event.getEventType() == GameEngine.Keyboard.KeyboardEvent.EVENT_PRESS);
alert("Key '"+event.getKeyNumber()+"' has been "+(pressed?"pressed":"released")+".");
}
GameEngine.Keyboard.addKeyboardListener(keyboardListener);
Returns
The ID of the intercepted key.