Class: HotkeyClient

Hotkey Client (Finsemble Flow)

This module contains Finsemble's Hotkey Client. Use this API to register event handlers for hotkeys (key combinations). Key combinations (sometimes referred to as "key chords") are defined as arrays. An example key combination is ["shift","ctrl","f"] which would trigger whenever a user presses those three keys simultaneously.

Common keys include "shift","ctrl","alt","backspace","tab","esc","enter","left","right,"up","down","space","pgup","pgdn". A complete list can be output by running: console.log(FSBL.Clients.HotkeyClient.keyMap). Take care to consider that not every keyboard contains every key.

Two types of hotkeys are supported: local hotkeys, which will only be triggered when the window which defined the hotkey is in focus, and global hotkeys, which will are triggered anytime, regardless of whether the window is in focus or not.

For more information, see the Hotkey tutorial.

Methods

addEventListener
(event, handler)

Name Type Description
event string
handler Function

addGlobalHotkey
(keyArr, handler, cb)

Adds a global hotkey which fires regardless of what window is in focus. If you execute this function more than once for the same key combination, both hotkeys will coexist, and would need to be removed separately.

Name Type Description
keyArr string[]

Array of strings representing a hotkey key combination.

handler Function | any

Function to be executed when the hotkey combination is pressed. It is recommended that you define a variable to represent the handler function, as the same function must be passed in order to remove the hotkey.

cb StandardCallback

The callback to be invoked if the method fails.

Example
var myFunction = function () {...}
FSBL.Clients.HotkeyClient.addGlobalHotkey(["ctrl", "shift", "s"], myFunction, cb)

addListener
(event, handler)

Name Type Description
event any
handler any

addLocalHotkey
(keyArr, handler, cb)

Adds a local hotkey which fires only when the window calling the method is in focus. If you execute this function more than once for the same key combination, both hotkeys will coexist, and would need to be removed separately.

Name Type Description
keyArr string[]

Array of strings representing hotkey key combination.

handler Function | any

Function to be executed when the hotkey combination is pressed. It is recommended that you define a variable to represent the handler function, as the same function must be passed in order to remove the hotkey.

cb StandardCallback

The callback to be invoked if the method fails.

Example
var myFunction = function () {...}
FSBL.Clients.HotkeyClient.addLocalHotkey(["ctrl", "shift", "s"], myFunction, cb)

cleanup
()

removeAllHotkeys
(cb)

Unregister all hotkeys, both locally and service-side.

Name Type Description
cb StandardCallback

The callback to be invoked if the method fails.

removeEventListener
(event, handler)

Name Type Description
event any
handler any

removeGlobalHotkey
(keyArr, handler, cb)

Removes a global hotkey.

Name Type Description
keyArr string[]

Array of strings representing hotkey key combination.

handler Function | any

Handler registered for the hotkey to be removed.

cb StandardCallback

The callback to be invoked if the method fails.

Example

FSBL.Clients.HotkeyClient.removeGlobalHotkey(["ctrl", "shift", "s"], myFunction, cb)

removeListener
(event, handler)

Name Type Description
event any
handler any

removeLocalHotkey
(keyArr, handler, cb)

Removes a local hotkey.

Name Type Description
keyArr string[]

Array of strings representing hotkey key combination.

handler Function | any

Handler registered for the hotkey to be removed.

cb StandardCallback

The callback to be invoked if the method fails.

Example

FSBL.Clients.HotkeyClient.removeLocalHotkey(["ctrl", "shift", "s"], myFunction, cb)