lz.KeysService
Keyboard input service.

JavaScript: lz.KeysService
extends lz.Eventable »

lz.Keys is the single instance of the class lz.KeysService.

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 16. lz.Keys

<canvas height="250" debug="true">
   <debug height="90%"/>
   <handler name="onkeydown" reference="lz.Keys" args="k">
     Debug.debug("key %w %s", k, "down");
   </handler>
   <handler name="onkeyup" reference="lz.Keys" args="k">
     Debug.debug("key %w %s", k, "up");
   </handler>
   <method name="pressA" args="ignore=null">
     Debug.debug("A pressed");
   </method>
   <handler name="oninit">
     var del = new LzDelegate(this, "pressA");
     lz.Keys.callOnKeyCombo(del, ["A"]);
   </handler>
 </canvas>

Attributes

Name (CSS property) 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.

Class Attributes

Name (CSS property) Type (tag) Type (js) Default Category
LzKeys   lz.KeysService   readonly
  The key service. Also available as the global lz.Keys.

Methods

callOnKeyCombo()
lz.KeysService.callOnKeyCombo(d : lz.handler, 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 lz.handler 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()
lz.KeysService.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()
lz.KeysService.removeKeyComboCall(d : lz.handler, kCArr : Array);
Removes the request to call the delegate on the keycombo.
Parameter Name Type Description
d lz.handler The delegate that was to be called when the keycombo was down.
kCArr Array An array of strings indicating which keys constituted the keycombo.

setGlobalFocusTrap()
lz.KeysService.setGlobalFocusTrap(istrapped);
Called to set/unset global focus trapping
Parameter Name Type Description
istrapped    

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
onkeydown Sent when a key is pressed; sent with keycode for key that was pressed.
onkeyevent Sent for all key events
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 lz.Eventable

ondestroy