Keyboard input service.
This service handles keyboard input events.
Here is a simple example:
<canvas height="140" debug="true">
<handler name="onkeydown" reference="LzKeys" args="k">
Debug.write("key " + k + " down");
</handler>
<handler name="onkeyup" reference="LzKeys" args="k">
Debug.write("key " + k + " up");
</handler>
<method name="pressA">
Debug.write("A pressed");
</method>
<handler name="oninit">
del = new LzDelegate(this, "pressA");
LzKeys.callOnKeyCombo(del, ["A"]);
</handler>
</canvas>
| Attributes | |||||
| Name | Usage | Type (Tag) | Type (JS) | Default | Category |
| downKeysArray | JS only | Array of Number | readonly | ||
| An array of currently pressed key codes. | |||||
|
|
|||||
| downKeysHash | JS only | Object | readonly | ||
| A hash where each of the keys that is currently down on the keyboard is set to true. | |||||
|
|
|||||
| keyCodes | JS only | Object | readonly | ||
| A hash that maps key names to key codes. | |||||
|
|
|||||
| mousewheeldelta | JS only | Number | readonly | ||
| the amount the mouse wheel last moved. Use onmousewheeldelta to learn when this value changes. | |||||
|
|
|||||
| callOnKeyCombo() | ||
| LzKeys.callOnKeyCombo(d, kCArr) | ||
|
Instructs the service to call the given delegate whenever the given key combination is pressed. The names for recognized special keys are (case-insensitive):
|
||
| Parameters | ||
| Name | Type | Desc |
| d | LzDelegate | The delegate to be called when the keycombo is down. |
| kCArr | [String] | Array of strings indicating which keys constitute the keycombo. This array may be in any order. |
|
|
||
| getDownKeys() | ||
| LzKeys.getDownKeys() | ||
| Returns | ||
| Type | Desc | |
| [Number] | array of keys codes that are currently down | |
|
|
||
| isKeyDown() | ||
| LzKeys.isKeyDown(k) | ||
| Parameters | ||
| Name | Type | Desc |
| k | String | The name of the key to check for downness or an array of key names (e.g. ['shift', 'tab'] |
| Returns | ||
| Type | Desc | |
| Boolean | indicating whether the given key is down. | |
|
|
||
| removeKeyComboCall() | ||
| LzKeys.removeKeyComboCall(d, kCArr) | ||
|
Removes the request to call the delegate on the keycombo. |
||
| Parameters | ||
| Name | Type | Desc |
| d | LzDelegate | The delegate that was to be called when the keycombo was down. |
| kCArr | [String] | An array of strings indicating which keys constituted the keycombo. |
|
|
||
| Events | |
| Name | Description |
| onkeydown | None |
| onkeyup | None |
Copyright © 2002-2005 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.