Skip to main content

Module: HotkeyClient

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);

Keep in mind that not every keyboard contains every key.

Finsemble supports 2 types of hotkeys: local hotkeys, which are triggered only when the window that defined the hotkey is in focus, and global hotkeys, which are triggered anytime regardless of whether the window is in focus or not.

For more info, see the Hotkey tutorial.

Functions​

addGlobalHotkey​

▸ addGlobalHotkey(keyArr, handler, cb?): StandardPromise<void>

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.

var myFunction = function () {};
FSBL.Clients.HotkeyClient.addGlobalHotkey(
["ctrl", "shift", "s"],
myFunction,
(err) => {
if (er) {
// Hotkey failed to register
}
},
);

const { err } = await FSBL.Clients.HotkeyClient.addGlobalHotkey(
["ctrl", "shift", "s"],
myFunction,
);
if (err) {
// Hotkey failed to register
}

Parameters​

NameTypeDescription
keyArrstring[]Array of strings representing a hotkey key combination.
handleranyFunction 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?StandardErrorCallback<void>Callback to be called after local hotkey is added.

Returns​

StandardPromise<void>


addLocalHotkey​

▸ addLocalHotkey(keyArr, handler, cb?): StandardPromise<void>

deprecated Use HTML5 key events when a window is in focus.

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.

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

Parameters​

NameTypeDescription
keyArrstring[]Array of strings representing hotkey key combination.
handler(...args: any[]) => voidFunction 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?StandardErrorCallback<void>Callback to be called after local hotkey is added.

Returns​

StandardPromise<void>


removeAllHotkeys​

▸ removeAllHotkeys(cb?): StandardPromise<void>

Unregister all hotkeys, both locally and service-side.

Parameters​

NameTypeDescription
cb?StandardErrorCallback<void>Optional callback function

Returns​

StandardPromise<void>


removeGlobalHotkey​

▸ removeGlobalHotkey(keyArr, handler, cb?): StandardPromise<void>

Removes a global hotkey.

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

const { err } = await FSBL.Client.HotkeyClient.removeGlobalHotkey([
"ctrl",
"shift",
"s",
]);

Parameters​

NameTypeDescription
keyArrstring[]Array of strings representing hotkey key combination.
handleranyHandler registered for the hotkey to be removed.
cb?StandardErrorCallback<void>Callback to be called after local hotkey is removed.

Returns​

StandardPromise<void>


removeLocalHotkey​

▸ removeLocalHotkey(keyArr, handler, cb?): StandardPromise<void>

deprecated Use HTML5 key events when a window is in focus.

Removes a local hotkey.

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

Parameters​

NameTypeDescription
keyArrstring[]Array of strings representing hotkey key combination.
handler(...args: any[]) => voidHandler registered for the hotkey to be removed.
cb?StandardErrorCallback<void>Callback to be called after local hotkey is removed.

Returns​

StandardPromise<void>