Skip to content
Reference > AmiScript API > Classes

Keyboard

Definition

Keyboard var = .... ;

Extends

Extended By

None

Description

The session's hotkeys: key combinations bound to actions

Method Summary

Owner Name Return Type Description
Keyboard bind(keys, action) Boolean Binds a key combination to an action for this session, above the layout's and the developer's bindings. Not saved with the layout. Pressing the keys calls the layout's onHotkey(action, event) and then the action's built-in behaviour, if any. Returns false, and binds nothing, if keys or action is not valid.
Keyboard bind(keys, action, scope, input) Boolean Binds a key combination to an action for this session, saying when the binding is in force and whether it applies while typing. Returns false, and binds nothing, if any argument is not valid.
Keyboard getAction(keys) String Returns the action the key combination triggers right now (it depends on whether the layout is being edited), or null if none.
Keyboard getBindings() Map Returns the bindings in force right now, as a map of key combination to action, e.g. {Ctrl+S=layout.save}. A Ctrl binding is listed once, as Ctrl; it also answers to Cmd on a Mac.
Object getClassName() String Returns the string name of this object's class type.
Keyboard normalize(keys) String Returns the key combination in the form KeyEvent::getKeys() reports it, e.g. normalize("shift+ctrl+z") is Ctrl+Shift+Z. Returns null if it is not a key combination.
Object toJson() String Returns a string of a json representation of this object.
Keyboard unbind(keys) Boolean Removes a binding made with bind(...), so the layout's or developer's binding for those keys, if any, applies again. To switch keys off entirely, bind them to none instead. Returns false if this session had no binding for the keys.

Method Definitions


bind(keys,action)

Boolean Keyboard::bind(String keys, String action)

Description

Binds a key combination to an action for this session, above the layout's and the developer's bindings. Not saved with the layout. Pressing the keys calls the layout's onHotkey(action, event) and then the action's built-in behaviour, if any. Returns false, and binds nothing, if keys or action is not valid.

Parameter Definition

Name Type Description
keys String  key combination, e.g. Ctrl+Shift+S, Alt+Enter or F2; Ctrl means Ctrl on Windows and Linux and Cmd on a Mac
action String  layout.save, layout.toggleEditMode, none (switches the keys off), or a name of your own, which the layout's onHotkey callback receives when the keys are pressed

bind(keys,action,scope,input)

Boolean Keyboard::bind(String keys, String action, String scope, String input)

Description

Binds a key combination to an action for this session, saying when the binding is in force and whether it applies while typing. Returns false, and binds nothing, if any argument is not valid.

Parameter Definition

Name Type Description
keys String  key combination, e.g. Ctrl+Shift+S, Alt+Enter or F2; Ctrl means Ctrl on Windows and Linux and Cmd on a Mac
action String  layout.save, layout.toggleEditMode, none (switches the keys off), or a name of your own
scope String  any (Dev and End User Mode), edit (Dev Mode only) or view (End User Mode only); null for the action's default
input String  field (a focused field that uses the keys, such as for typing, copy or undo, keeps them; otherwise the shortcut runs) or always (the shortcut runs even while typing); null for the action's default

getAction(keys)

String Keyboard::getAction(String keys)

Description

Returns the action the key combination triggers right now (it depends on whether the layout is being edited), or null if none.

Parameter Definition

Name Type Description
keys String  key combination, e.g. Ctrl+Shift+S, Alt+Enter or F2; Ctrl means Ctrl on Windows and Linux and Cmd on a Mac

getBindings()

Map Keyboard::getBindings()

Description

Returns the bindings in force right now, as a map of key combination to action, e.g. {Ctrl+S=layout.save}. A Ctrl binding is listed once, as Ctrl; it also answers to Cmd on a Mac.


getClassName()

String Object::getClassName()

Description

Returns the string name of this object's class type.


normalize(keys)

String Keyboard::normalize(String keys)

Description

Returns the key combination in the form KeyEvent::getKeys() reports it, e.g. normalize("shift+ctrl+z") is Ctrl+Shift+Z. Returns null if it is not a key combination.

Parameter Definition

Name Type Description
keys String  key combination, e.g. Ctrl+Shift+S, Alt+Enter or F2; Ctrl means Ctrl on Windows and Linux and Cmd on a Mac

toJson()

String Object::toJson()

Description

Returns a string of a json representation of this object.


unbind(keys)

Boolean Keyboard::unbind(String keys)

Description

Removes a binding made with bind(...), so the layout's or developer's binding for those keys, if any, applies again. To switch keys off entirely, bind them to none instead. Returns false if this session had no binding for the keys.

Parameter Definition

Name Type Description
keys String  key combination, e.g. Ctrl+Shift+S, Alt+Enter or F2; Ctrl means Ctrl on Windows and Linux and Cmd on a Mac