Question: How to actively check if a certain (decoration) key is pressed, like CTRL or SHIFT, like:
if (SomeKeyboardRelatedService.isControlPressed()) {...}
background
I'd like to check if a certain (decoration) key is pressed when the user clicks the mouse. We cannot manage to do it actively.
Instead, we are using RawKeyboardListener
and remember the isControlPressed
in onKey
event. This way, later in GestureDetector.onTap
we can check if isControlPressed
is true
. The problem is:
- It seems nowhere reasonable to maintain the key pressed state on our own, as it violated the single-source-of-truth principle and may cause inconsistency.
- It actually IS causing inconsistency, if the user switches away from the app while holding the special key.
We have read relevant docs and searched with several keywords and ended up with no result.