GlobalShortcut
Register global keyboard shortcuts.
Module | require("gui") |
Type | Object |
This class can not be created by user, you can only receive its global
instance from the globalShortcut
property of the module:
gui.globalShortcut.unregisterAll()
Methods
register(accelerator, callback)
Register a global keyboard shortcut that, callback
will called when the
accelerator
is pressed.
An unsigned ID will returned on success, which can be used to undo the registration. -1 will be returned on error.
This API will fail silently when the accelerator is already taken by other apps, there is no way to know if an accelerator has already been registered by other apps.
Parameters
Accelerator
acceleratorFunction
callback
Return
Integer
unregister(id)
Unregister the shortcut with the id
returned by register
.
Parameters
Integer
id
unregisterAll()
Unregister all shortcuts registered in this app.