var app = require('app');
var globalShortcut = require('electron').globalShortcut;
app.on('ready', function() {
var ret = globalShortcut.register('ctrl+x', function() {
console.log('ctrl+x is pressed');
})
if (!ret) {
console.log('registration failed');
}
console.log(globalShortcut.isRegistered('ctrl+x'));
});
app.on('will-quit', function() {
globalShortcut.unregister('ctrl+x');
globalShortcut.unregisterAll();
});
Methods
globalShortcut.register(accelerator, callback)
accelerator
Acceleratorcallback
Function
globalShortcut.isRegistered(accelerator)
globalShortcut.unregister(accelerator)
globalShortcut.unregisterAll()
请发表评论