musescore / MuseScore

MuseScore is an open source and free music notation software. For support, contribution, bug reports, visit MuseScore.org. Fork and make pull requests!
https://musescore.org
Other
12.14k stars 2.63k forks source link

[NO MERGE] Report pressed keys #24986

Open shoogle opened 15 hours ago

shoogle commented 15 hours ago

Following discussions in PR #24958, it would be useful to know how Qt is reporting keypresses on each platform. (Perhaps we should add a keylogger to the Diagnostic menu?)

For now, this PR just prints keys on the console. Download the artifact and run it on the command line to see how Qt reports keys on your system. On Windows it might be necessary to run it in Qt Creator or another debugger/IDE to see the console output.

Results with UK QWERTY PC keyboard on Windows

On this keyboard, + is entered with Shift =, thus combinations involving Shift = are conceptually using +.

On this platform, Qt's portable key names are equivalent to the native key names (at least in English).

Physical keys pressed Conceptual keys Qt portable/native keys Qt text
= = = =
Alt = Alt = Alt+= =
Ctrl = Ctrl = Ctrl+= =
Ctrl Alt = Ctrl Alt = ⚠️ Main window: Alt+=
Dialogs: Ctrl+Alt+=
=
Shift = + Shift++ +
Alt Shift = Alt + Alt+Shift++ +
Ctrl Shift = Ctrl + Ctrl+Shift++ ⚠️ =
Ctrl Alt Shift = Ctrl Alt + Ctrl+Alt+Shift++ ⚠️ =
Markdown ```Markdown Physical keys pressed | Conceptual keys | Qt portable/native keys | Qt text ---:|---:|---:|---: Ctrl Alt = | Ctrl Alt = | ⚠️ Main window: `Alt+=`
Dialogs: `Ctrl+Alt+=` | `=` ```

Reasonable people can disagree over whether it's better to show physical or conceptual keys in Preferences > Shortcuts. The real question is, which of those things (physical or conceptual) can we reliably determine based on the information Qt is reporting?

With this particular OS (Windows), keyboard layout (UK QWERTY PC), and key (=), it seems that dropping Shift from Qt's reported keys does give a reasonable approximation of the conceptual keys (but we know that's not the case for all keys).

There doesn't seem to be a straightforward way to determine the physical keys pressed. It might be possible using native methods as demonstrated here. However, the output of these methods is platform-specific.