input-remapper icon indicating copy to clipboard operation
input-remapper copied to clipboard

Key acting normally if pressed alone, as modifier if combined

Open jose1711 opened this issue 2 years ago • 6 comments

Let's say I would like to use Space as a Left CTRL+Left Alt modifier but only if it's used in combination with other key.

Single Space would generate a " ". Space + Del would bring up a shutdown dialog/lock screen etc.

Closest I was able to get is:

space = if_single(k(KEY_SPACE), h(m(KEY_LEFTCTRL, k(KEY_LEFTALT))))

It works only partially as it looks like the modifiers are released before the second key is registered (OS probably sees Left CTRL+Left Alt and Del as separate events).

jose1711 avatar Feb 08 '22 16:02 jose1711

hold will repeat calling the modify macro (see https://github.com/sezanzeb/input-remapper/blob/main/readme/macros.md#hold)

try

space = if_single(key(KEY_SPACE), modify(KEY_LEFTCTRL, hold(KEY_LEFTALT)))

sezanzeb avatar Feb 08 '22 17:02 sezanzeb

thank you. it's much better although it does not react immediately. instead i have to press Del twice so a working sequence is as follows:

  • press and hold Space
  • tap Del (and Del is interpreted normally, i. e. a character is erased)
  • tap Del again
  • release Space

jose1711 avatar Feb 08 '22 22:02 jose1711

Try to reduce keystroke_sleep_ms to 0 in the config json: https://github.com/sezanzeb/input-remapper/blob/main/readme/usage.md#configuration-files

either the global json, or the json of your preset

sezanzeb avatar Feb 08 '22 22:02 sezanzeb

Thank you, that worked. The documentation does not currently detail what is the purpose of this setting (apparently cases like these) or what are the implications (performance?).

jose1711 avatar Feb 08 '22 23:02 jose1711

Early during development I observed that it would not inject the key macros properly when the timeout is too small.

Let me know if you are facing any issues, maybe defaulting this setting to 10 is obsolete

sezanzeb avatar Feb 09 '22 00:02 sezanzeb

The Del event is already ready to be injected, but the macro uses timeouts, so the else macro is started too late. The Del event is injected before KEY_LEFTALT is injected.

sezanzeb avatar Feb 09 '22 00:02 sezanzeb