Failed global shortcut registration in nw.App.registerGlobalHotKey
0 reputation · 11 Apr 2023, 00:55 UTC
Failed global shortcut registration in nw.App.registerGlobalHotKey
When an NW.js application calls nw.App.registerGlobalHotKey, the API returns a boolean. A return value of false indicates that the registration did not succeed, but the documentation does not expose the underlying reason—whether the shortcut is already in use by another process, the accelerator string is malformed, or the platform does not support the requested combination.
Because the API offers no error code or message, developers cannot programmatically differentiate these cases. This uncertainty becomes critical when an app needs to reconfigure its global hotkeys at runtime or when it must decide whether to attempt a re‑registration after a failure.
Additionally, the documentation does not specify whether unregistering a shortcut that was never successfully registered is a no‑op, a no‑error, or an error condition. The same ambiguity applies to calling nw.App.unregisterGlobalHotKey after a failed registration.
Key questions for clarification:
- Should an application call
nw.App.unregisterGlobalHotKeybefore attempting to re‑register the same shortcut, and is this safe if the original registration failed? - Does re‑registering a previously failed shortcut succeed on subsequent attempts, or does the failure state persist?
- Is there a platform‑specific difference in how
registerGlobalHotKeyreports failures, and can the API be extended to provide diagnostic details?