houmain / keymapper

A cross-platform context-aware key remapper.
GNU General Public License v3.0
295 stars 25 forks source link

When running in macOS it breaks the F1-F12 row #120

Closed TheMasterDingo closed 5 months ago

TheMasterDingo commented 6 months ago

I got a new MBP M3 and decided to install keymapper here aswell.

Installed the karabiner-virtualHIDDevice then keymapper through brew.

I did not notice at first but the F1-F12 row(which contains also volume, media keys, brightness, etc) did not work. I tested the keys on https://www.toptal.com/developers/keycode and i saw that it sees only F1-F12. Basically it does not send the 'special keys'. There is also an option in macOS that it deafualts to the F1-F12 row but i made sure it is disabled, hitting fn key and the F1-F12 row does still not send the other keys.

If i disable keymapper everything works well.

ristomatti commented 6 months ago

I'm just guessing here, I don't own a Mac, but I perhaps this is what's happening:

If the above is correct, you could try mapping the F-key codes manually to their special functions in the beginning of the config. This could be done with just 2 lines of config If the Fn key on the keyboard sends a keycode keymapper can see*. Example:

FunctionKey = F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12
FunctionKey >> Fn{FunctionKey}

*) In Key.h there at least seems to be a mapping for Fn key: https://github.com/houmain/keymapper/blob/5250c94839c3d365b9f4c1e2ec2c0fc45bff53e9/src/runtime/Key.h#L439

If this fails, then map the F-keys to the special keycodes one by one, e.g.:

F1 >> BrightnessDown
F2 >> BrightnessUp
# etc

You'll find all the supported key names in src/runtime/Key.h.

ristomatti commented 6 months ago

If my suggestion above works, it gives the flexibility of handling the F-key behavior differently depending on the app. If for example you want them work as special keys by default but have use for F1-F12 on a code editor, you can add a context block first that targets the code editor, then add those mappings in the end of the config. Something like:

FunctionKey = F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12

[class="Code"]
  FunctionKey >> FunctionKey

[default]
  FunctionKey >> Fn{FunctionKey}
TheMasterDingo commented 6 months ago

I just tried both methods but it does not work. When i tried the Fn key in https://www.toptal.com/developers/keycode it sees nothing.

Even if i do a manual F1 >> BrightnessDown it does not work

ristomatti commented 6 months ago

Have you tried how Karabiner EventViewer shows the keypresses https://karabiner-elements.pqrs.org/docs/manual/operation/eventviewer/? Note that I'm literally googling, I have no clue what the issue could be. 🙂

Or does the Fn key event show up in https://www.toptal.com/developers/keycode when keymapper is not running?

TheMasterDingo commented 6 months ago

Hm no i haven't tried Karabiner EventViewer. the toptal website does not see the Fn key at all, with or without keymapper running. (even when using this https://www.hexcore.xyz/kbdtool it does not see the Fn)

houmain commented 6 months ago

Thanks for reporting. I will test it soon on a recent Apple device myself. Hopefully I can reproduce it.

houmain commented 5 months ago

This should be fixed with the 4.1.2 release.