Description
Thanks for the great work you do on Electron. 🙏We love using Electron.
I'm setting up a MenuItem with an "accelerators" (keyboard shortcuts). I'm specifying the click
option to provide custom handling. In my analytics, I'd like to report the method the user used to trigger the MenuItem—mouse click or keyboard shortcut.
The click
function I provide is called with these arguments: (menuItem, browserWindow, event)
. The value of event
is { shiftKey: false, ctrlKey: false, altKey: false, metaKey: false }
. For accelerators that happen to include one of the keys in event
, I'm able to derive that the user hit the keyboard shortcut (i.e. if the user hits the keyboard shortcut for Command-C
, event
will contain metaKey: true
.
But some of my keyboard shortcuts are: Up
, Down
, Enter
. If the user hits these keyboard shortcuts, I have no way to differentiate whether the user clicked the menu item with the mouse or hit the keyboard shortcut.
Is there a reliable way to differentiate mouse clicks vs. keyboard shortcut hits in a MenuItem?