New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: unable to bind to volume events using globalShortcut from Touch bar #30588
Comments
Thanks for reporting this and helping to make Electron better! Because of time constraints, triaging code with third-party dependencies is usually not feasible for a small team like Electron's. Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use. Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests. I'm adding the |
Fixed in #31492, tested with: // The globalShortcut module can register/unregister a global keyboard shortcut
// with the operating system so that you can customize the operations for various
// shortcuts.
//
// Note: The shortcut is global; it will work even if the app does not have the
// keyboard focus. You should not use this module until the ready event of the
// app module is emitted. In this example, we're using "Accelerators":
// Accelerators are Strings that can contain multiple modifiers and key codes,
// combined by the + character, and are used to define keyboard shortcuts
// throughout your application.
//
// For more info, see:
// https://electronjs.org/docs/api/accelerator
// https://electronjs.org/docs/api/global-shortcut
const { app, globalShortcut } = require('electron')
app.whenReady().then(() => {
// Register a 'CommandOrControl+Y' shortcut listener.
//
// On Linux and Windows, the Command key does not have any effect, so use
// CommandOrControl which represents Command on macOS and Control on
// Linux and Windows to define some accelerators.
globalShortcut.register('CommandOrControl+Y', () => {
console.log('The global shortkey was pressed!')
})
// It supports "special names". Check out the API documentation for a full
// list.
globalShortcut.register('VolumeUp', () => console.log('Turn it up!'))
globalShortcut.register('VolumeDown', () => console.log('Turn it down!'))
globalShortcut.register('MediaPlayPause', () => console.log('Stop media!'))
})
app.on('will-quit', () => {
// Unregister a shortcut.
globalShortcut.unregister('CommandOrControl+Y')
// Unregister all shortcuts.
globalShortcut.unregisterAll()
}) |
Preflight Checklist
Electron Version
12.0.16
What operating system are you using?
macOS
Operating System Version
Big Sur 11.4
What arch are you using?
arm64 (including Apple Silicon)
Last Known Working Electron version
No response
Expected Behavior
Binding to VolumeUp, VolumeDown or VolumeMute should work for TouchBar buttons.
Actual Behavior
Only VolumeMute fires.
Testcase Gist URL
No response
Additional Information
App has Accessibility permission. VolumeMute only fires when the permission is provided.
The text was updated successfully, but these errors were encountered: