IdleKeyCounter Macro (v9.0.2)

IdleKeyCounter Macro (v9.0.2)

I'll bet this will be the shortest useful macro in the history of KM. I wrote it because I wanted an equivalent to the IDLE() function that wasn't triggered by mouse movement, because mouse movements can be accidentally triggered by bumping the table or by a large truck driving past my house. This macro solves that by resetting a variable called IdleKey only when a character key (not by any mouse motion) is typed by the user. In my opinion this is more robust than the IDLE() function.

Since there is no ability to create a function in KM, if you have this macro active then the equivalent to "IDLE()" would be "MS-IdleKey". That's four extra characters, so it's not too bad. I suppose if you wanted to rename the variable IdleKey to T then you could write "MS-T" and it would be really short.

It might be nice to detect not only character keys, but also modifier keys and function keys. I don't think it's possible to trigger on a modifier key with KM. It is possible to trigger on a function key, however there's a small (not insurmountable) problem with that. The hotkey detection trigger eats the key it triggers on. I think KM should be modified with a flag to the HotKey detection trigger to let us "not eat" the key, just as there is with the string trigger used by this macro. If anyone asks I can enhance this macro to support function keys, but it would detract from the sheer beauty of this short macro.

I place this code into the public domain. It's free to use. No attribution required.

IdleKeyCounter.kmmacros (1.5 KB)