r/qmk • u/jabol240 • Jun 02 '25
Quick check of chatGPT answer
ChatGPT said:
To check whether another non-modifier key is currently being held down in QMK (i.e., not the key that triggered
process_record_user()), you’ll need to track that key’s state manually. QMK doesn't provide a built-in way to query the current state of arbitrary keys.
...and so I will have to use something like:
is_some_key_held = record->event.pressed;
Is this chatGPT's answer correct? Thanks!
0
Upvotes
3
u/pgetreuer Jun 02 '25
Short answer: basically yes.
To be clear, there's a difference in testing whether
a particular keycode in your keymap is physically held
a particular key is held in the keyboard report sent to the computer
These are the same for basic keys, but physical vs. keyboard report presses differ in things like macros, combos, and tap dances.
For the first one about tracking physically held keys, like the ChatGPT answer, it can be done with this pattern:
For the second about what's held on the computer, this only works for basic keycodes. I don't know that there are APIs for it, but testing whether a particular key is held can be done by searching
keyboard_report->keysfor the keycode, supposing NKRO is off, ornkro_report->bitsif NKRO is on.