8000 Differentiating a mouse click vs. keyboard shortcut hit in MenuItem click? · Issue #16947 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Differentiating a mouse click vs. keyboard shortcut hit in MenuItem click? #16947
Closed
@aguynamedben

Description

@aguynamedben

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?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0