LzKeysService
Keyboard input service.

JavaScript: LzKeysService
extends <node> » LzEventable »
lz.Keys is a service that provides key handling messages. Objects can also register callbacks to be sent when specific key combinitions are down.

Here is a simple example:

Example 24. lz.Keys

<canvas height="140" debug="true">
   <handler name="onkeydown" reference="lz.Keys" args="k">
     Debug.write("key " + k + " down");
   </handler>
   <handler name="onkeyup" reference="lz.Keys" args="k">
     Debug.write("key " + k + " up");
   </handler>
   <method name="pressA">
     Debug.write("A pressed");
   </method>
   <handler name="oninit">
     del = new LzDelegate(this, "pressA");
     lz.Keys.callOnKeyCombo(del, ["A"]);
   </handler> 
 </canvas>
edit

Attributes

Name Type (tag) Type (js) Default Category
mousewheeldelta Number Number 0 readonly
  The amount the mouse wheel last moved. Use the onmousewheeldelta event to learn when this value changes.

Methods

callOnKeyCombo()
LzKeysService.callOnKeyCombo(d : LzDelegate, kCArr : Array);
Instructs the service to call the given delegate whenever the given key combination is pressed. The names for recognized special keys are (case-insensitive):
  • numbpad0
  • numbpad1
  • numbpad2
  • numbpad3
  • numbpad4
  • numbpad5
  • numbpad6
  • numbpad7
  • numbpad8
  • numbpad9
  • multiply
  • enter
  • subtract
  • decimal
  • divide
  • f1
  • f2
  • f3
  • f4
  • f5
  • f6
  • f7
  • f8
  • f9
  • f10
  • f11
  • f12
  • backspace
  • tab
  • clear
  • enter
  • shift
  • control
  • alt
  • capslock
  • esc
  • spacebar
  • pageup
  • pagedown
  • end
  • home
  • leftarrow
  • uparrow
  • rightarrow
  • downarrow
  • insert
  • help
  • numlock
  • add
  • delete
  • 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • [
  • @
  • #
  • $
  • %
  • ^
  • &
  • *
  • *
  • (
  • )
  • ;
  • :
  • =
  • +
  • -
  • _
  • /
  • ?
  • ~
  • [
  • {
  • \
  • |
  • ]
  • }
  • "
  • '
Parameter Name Type Description
d LzDelegate The delegate to be called when the keycombo is down.
kCArr Array Array of strings indicating which keys constitute the keycombo. This array may be in any order.

isKeyDown()
LzKeysService.isKeyDown(k);
Parameter Name Type Description
k   The name of the key to check for downness or an array of key names, e.g. ['shift', 'tab']
Returns Type Description
  Boolean indicating whether the given key(s) are down.

removeKeyComboCall()
LzKeysService.removeKeyComboCall(d : LzDelegate, kCArr : Array);
Removes the request to call the delegate on the keycombo.
Parameter Name Type Description
d LzDelegate The delegate that was to be called when the keycombo was down.
kCArr Array An array of strings indicating which keys constituted the keycombo.

Methods inherited from LzEventable

destroy, setAttribute

Events

Name Description
onkeydown Sent when a key is pressed; sent with keycode for key that was pressed.
onkeyup Sent whenever a key goes up; sent with keycode for key that was let go.
onmousewheeldelta Sent when the mouse wheel changes state. Sent with a positive or negative number depending on the direction and amount the wheel moved.

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from LzEventable

ondestroy