KeyboardControls

KeyboardControls

This class allows easy usage of device keyboard controls. Use the method KeyboardControls#bindKey to generate events whenever a key is pressed.

Constructor

new KeyboardControls()

Source:
Example
// in the ClientEngine constructor
   this.controls = new KeyboardControls(this);
   this.controls.bindKey('left', 'left', { repeat: true } );
   this.controls.bindKey('right', 'right', { repeat: true } );
   this.controls.bindKey('space', 'space');

Methods

bindKey(keys, actionName, options, parameters)

Bind a keyboard key to a Lance client event. Each time the key is pressed, an event will be transmitted by the client engine, using ClientEngine#sendInput, and the specified event name.

Common key names: up, down, left, right, enter, shift, ctrl, alt, escape, space, page up, page down, end, home, 0..9, a..z, A..Z. For a full list, please check the source link above.

Parameters:
Name Type Description
keys String

keyboard key (or array of keys) which will cause the event.

actionName String

the event name

options Object

options object

Properties
Name Type Description
repeat Boolean

if set to true, an event continues to be sent on each game step, while the key is pressed

parameters Object/Function

parameters (or function to get parameters) to be sent to the server with sendInput as the inputOptions

Source: