input.js

This file contains a very simple input system.

Summary
input.jsThis file contains a very simple input system.
utContainer namespace.
Constants
Keycodes
Functions
isKeyPressedChecks if given key is pressed down.
setKeyRepeatIntervalSets the interval when user’s onKeyDown handler is called when a key is held down.
initInputInitilizes input by assigning default key handlers and optional user’s handlers.

ut

Container namespace.

Summary
Constants
Keycodes
Functions
isKeyPressedChecks if given key is pressed down.
setKeyRepeatIntervalSets the interval when user’s onKeyDown handler is called when a key is held down.
initInputInitilizes input by assigning default key handlers and optional user’s handlers.

Constants

Keycodes

KEY_BACKSPACE8
KEY_TAB9
KEY_ENTER13
KEY_SHIFT16
KEY_CTRL17
KEY_ALT18
KEY_ESCAPE27
KEY_SPACE32
KEY_LEFT37
KEY_UP38
KEY_RIGHT39
KEY_DOWN40
KEY_048
KEY_149
KEY_250
KEY_351
KEY_452
KEY_553
KEY_654
KEY_755
KEY_856
KEY_957
KEY_A65
KEY_B66
KEY_C67
KEY_D68
KEY_E69
KEY_F70
KEY_G71
KEY_H72
KEY_I73
KEY_J74
KEY_K75
KEY_L76
KEY_M77
KEY_N78
KEY_O79
KEY_P80
KEY_Q81
KEY_R82
KEY_S83
KEY_T84
KEY_U85
KEY_V86
KEY_W87
KEY_X88
KEY_Y89
KEY_Z90
KEY_NUMPAD096
KEY_NUMPAD197
KEY_NUMPAD298
KEY_NUMPAD399
KEY_NUMPAD4100
KEY_NUMPAD5101
KEY_NUMPAD6102
KEY_NUMPAD7103
KEY_NUMPAD8104
KEY_NUMPAD9105
KEY_F1112
KEY_F2113
KEY_F3114
KEY_F4115
KEY_F5116
KEY_F6117
KEY_F7118
KEY_F8119
KEY_F9120
KEY_F10121
KEY_F11122
KEY_F12123
KEY_COMMA188
KEY_DASH189
KEY_PERIOD190

Functions

isKeyPressed

ut.isKeyPressed = function(key)

Checks if given key is pressed down.  You must call ut.initInput first.

Parameters

keykey code to check

Returns

True if the key is pressed down, false otherwise.

setKeyRepeatInterval

ut.setKeyRepeatInterval = function(milliseconds)

Sets the interval when user’s onKeyDown handler is called when a key is held down.  ut.initInput must be called with a handler for this to work.

Parameters

millisecondsthe interval delay in milliseconds (1 second = 1000 milliseconds)

initInput

ut.initInput = function(onKeyDown,
onKeyUp)

Initilizes input by assigning default key handlers and optional user’s handlers.  This must be called in order to ut.isKeyPressed to work.

Parameters

onkeydown(optional) function(keyCode) for key down event handler
onkeyup(optional) function(keyCode) for key up event handler
ut.isKeyPressed = function(key)
Checks if given key is pressed down.
ut.setKeyRepeatInterval = function(milliseconds)
Sets the interval when user’s onKeyDown handler is called when a key is held down.
ut.initInput = function(onKeyDown,
onKeyUp)
Initilizes input by assigning default key handlers and optional user’s handlers.
Close