SLUDGE

onKeyboard


Syntax:

onKeyboard (handlerFunction);

onKeyboard ();

Purpose:

Tells the computer which function to call when a button on the keyboard is pressed. The value of handlerFunction must be a pointer to a function which takes one parameter. When a keyboard button is pressed, the function specified in handlerFunction will be called with the key which was pressed passed as a string to the parameter.

If no parameter is given, the program stops calling the current keyboard handler function. No function will be called when the user presses a keyboard button until another call to onKeyboard tells the machine otherwise.

Note that only one handler for the keyboard can be used at any one time. A subsequent call to onKeyboard will replace the current handler function.

For normal characters, your keyboard handler will simply by passed the individual character as a string. For some special characters, however, the handler will be passed a longer string, the content of which specifies what key has been pressed:

"ENTER" The player pressed either the enter or return key

"BACKSPACE" The player pressed the backspace key

"ESCAPE" The player pressed the escape key

"F1" - "F12" The player pressed one of the function keys

"DELETE" The player pressed the delete key

"INSERT" The player pressed the insert key

"HOME" The player pressed the home key

"END" The player pressed the end key

"PAGE UP" The player pressed the page up key

"PAGE DOWN" The player pressed the page down key

"UP", "DOWN", "LEFT", "RIGHT" The player pressed one of the cursor keys

"ALT+A" - "ALT+Z" The player held down Alt and pressed a letter

"ALT+F1" - "ALT+F12" The player held down Alt and pressed a function key

Note that, at least on the machines on which SLUDGE has been tested so far, pressing F10 will generate an "ALT+F10" message, not an "F10" message as you'd reasonably expect. Also, it seems to be oblivious to users holding down Alt and hitting F6 for some reason. Go figure.

To capture a wider range of keypresses, use the captureAllKeys command.

Return value:

No return value.

See also:

Passing Functions as Variables

onFocusChange

onFocusChange

onLeftMouse

onLeftMouseUp

onMoveMouse

onRightMouse

onRightMouseUp