phil294 / AHK_X11

AutoHotkey for Linux (X11-based systems)
GNU General Public License v2.0
815 stars 15 forks source link

Key repeat for remapped keys #68

Open davuses opened 10 months ago

davuses commented 10 months ago

Key repeat is not enabled on remapped keys. If I remap up key to combination alt+shift+k, I have to keep hitting k to go up multiple lines.

!+k::Send {UP}       ; i UP          (Cursor up line)

By comparison the up key can automatically move cursor up multiple lines when I press it.

I'm running AHK_X11 on KDE.

phil294 commented 10 months ago

yeah that's pretty annoying

davuses commented 10 months ago

yeah that's pretty annoying

Any workaround for this issue?

phil294 commented 10 months ago

Sure, you can write your own key repeat logic:

!+k::
send {up}
sleep 300
loop
{
  sleep 100 ; or how fast else you want this to behave
  GetKeyState, state, k
  if state != D
    break
  send {up}
}
return

Stuff like this may contain bugs (e.g. #26), but this very code sample seems to work fine.

The only downside I can see is that it doesn't synchronize with the actual key repeat configured for your system.

If you have many such remaps, you could even generalize this into a routine that uses the Hotkey command to register them, so then you'll do

hotkey_from = !+k
hotkey_to = {up}
GoSub, register_repeating_hotkey