FORGE. KeyBinding

new KeyBinding(viewer, keysIn, downopt, nullable, upopt, nullable, holdopt, nullable, keysOutopt, nullable, contextopt, nameopt)

Key Binding object that handles keyboard event handlers for a list of keycodes. To use a Key Binding you have to add it to the FORGE.Keyboard.
Parameters:
Name Type Attributes Description
viewer FORGE.Viewer The viewer reference.
keysIn Array.<number> | number The key code or array of key codes associated to this KeyBinding.
down function | string | Array.<string> <optional>
<nullable>
The callback function that will be called on a keydown event.
up function | string | Array.<string> <optional>
<nullable>
The callback function that will be called on a keyup event.
hold function | string | Array.<string> <optional>
<nullable>
The callback function that will be called if a key down is hold.
keysOut Array.<number> | number <optional>
<nullable>
The key code or array of key codes that will be rejected if this KeyBinding is pressed.
context Object <optional>
The context in which you want your "down", "hold" & up callbacks to execute
name string <optional>
The name of the binding, can be use as an identifier.
Source:

Extends

Members

(readonly) alive :boolean

Get the alive flag value of the object.
Type:
  • boolean
Inherited From:
Source:

(readonly) className :string

Get the class name of the object.
Type:
  • string
Inherited From:
Source:

data :*

Get and set any custom data you want to associate to this object.
Type:
  • *
Inherited From:
Source:

debug :boolean

Get and set the debug flag.
Type:
  • boolean
Inherited From:
Source:

(readonly) downComplete :boolean

Gets the downComplete value.
Type:
  • boolean
Source:

(readonly) downCount :number

Gets the down count value.
Type:
  • number
Source:

(readonly) hasToWaitToHold :boolean

Gets the hasToWaitToHold value.
Type:
  • boolean
Source:

(readonly) holdCount :number

Gets the hold count value.
Type:
  • number
Source:

(readonly) name :string

Gets the name of this BaseBinding.
Type:
  • string
Inherited From:
Source:

(readonly) onDestroy :FORGE.EventDispatcher

Get the onDestroy FORGE.EventDispatcher, this event is emitted at the end of the destroy sequence.
Type:
Inherited From:
Source:

(readonly) pressed :boolean

Gets the pressed status of this KeyBinding.
Type:
  • boolean
Source:

(readonly) tags :Array

Get the tags associated to this object.
Type:
  • Array
Inherited From:
Source:

(readonly) type :string

Gets the type of this BaseBinding.
Type:
  • string
Inherited From:
Source:

(readonly) uid :string

Get the uid of the object.
Type:
  • string
Inherited From:
Source:

(readonly) upCount :number

Gets the up count value.
Type:
  • number
Source:

warning :boolean

Get and set the warning flag.
Type:
  • boolean
Inherited From:
Source:

Methods

_boot()

Boot sequence
Source:

destroy()

Destroy sequence.
Overrides:
Source:

down(event)

This method is called by the FORGE.Keyboard when a key down event is applied.
This triggers the down callback associated to this KeyBinding and increase the downCount value.
Parameters:
Name Type Description
event KeyboardEvent The keyboardEvent from the keydown user action.
Source:

hasKeyIn(keyCode) → {boolean}

Know if a key code is associated to this KeyBinding.
Parameters:
Name Type Description
keyCode number The key code you want to know if it is associated to this KeyBinding.
Source:
Returns:
Returns true if the keycode is associated as a key in to this KeyBinding.
Type
boolean

hasKeyOut(keyCode) → {boolean}

Know if a key code is considered as a key out for this KeyBinding.
Parameters:
Name Type Description
keyCode number The key code you want to know if it is considered as a key out for this KeyBinding.
Source:
Returns:
Returns true if the key code is considered as a key out for this KeyBinding.
Type
boolean

hold()

This method is called by the FORGE.Keyboard when a key hold event is applied.
This triggers the hold callback associated to this KeyBinding and increase the holdCount value.
Source:

log(value)

Basic log method, log a string in the console if debug is enabled.
Parameters:
Name Type Description
value * The value you want to log in the console.
Inherited From:
Source:

up(event)

This method is called by the FORGE.Keyboard when a key up event is applied.
This triggers the up callback associated to this KeyBinding and increase the upCount value.
Parameters:
Name Type Description
event KeyboardEvent The keyboardEvent from the keyup user action.
Source:

waitToHold() → {function}

This method has to be called by the user down callback to specify that the key down have to wait to be considered as holded.
This gives in return a callback to set the down as complete.
Source:
Returns:
Returns a callback function that the user have to call to set the down as complete to allow hold.
Type
function

warn(valuenullable)

Basic warn method, log a warn string in the console if warning is enabled.
Parameters:
Name Type Attributes Description
value string | Object <nullable>
The value you want to warn in the console.
Inherited From:
Source:

FORGE. KeyBinding

Members
Methods