This file contains a very simple input system.
| input.js | This file contains a very simple input system. |
| ut | Container namespace. |
| Constants | |
| Keycodes | |
| Functions | |
| isKeyPressed | Checks if given key is pressed down. |
| setKeyRepeatInterval | Sets the interval when user’s onKeyDown handler is called when a key is held down. |
| initInput | Initilizes input by assigning default key handlers and optional user’s handlers. |
Container namespace.
| Constants | |
| Keycodes | |
| Functions | |
| isKeyPressed | Checks if given key is pressed down. |
| setKeyRepeatInterval | Sets the interval when user’s onKeyDown handler is called when a key is held down. |
| initInput | Initilizes input by assigning default key handlers and optional user’s handlers. |
ut.isKeyPressed = function( key )
Checks if given key is pressed down. You must call ut.initInput first.
| key | key code to check |
True if the key is pressed down, false otherwise.
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.
| milliseconds | the interval delay in milliseconds (1 second = 1000 milliseconds) |
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.
| onkeydown | (optional) function(keyCode) for key down event handler |
| onkeyup | (optional) function(keyCode) for key up event handler |
Checks if given key is pressed down.
ut.isKeyPressed = function( key )
Sets the interval when user’s onKeyDown handler is called when a key is held down.
ut.setKeyRepeatInterval = function( milliseconds )
Initilizes input by assigning default key handlers and optional user’s handlers.
ut.initInput = function( onKeyDown, onKeyUp )