dnicolson / Bluetooth-Keyboard-Enhancer

⌨️ Enables missing functionality on iOS keyboards
15 stars 1 forks source link

Here's a simpler way to remap the home button to escape #5

Open szhu opened 3 years ago

szhu commented 3 years ago

Hi, thank you so much for making this repo. I have spent way too many hours researching how to remap the home button to escape before finally coming across your program, which does exactly that. (In case how you're wondering how I found this repo, my path was Google -> Ask Different -> this repo.)

I want to point out that there's a simpler way to handle remapping, using Apple's hidutil. Apple has a Technical Note describing the usage: https://developer.apple.com/library/archive/technotes/tn2450/_index.html. Note that mappings created this way only persist until logout. (Someone made https://github.com/amarsyla/hidutil-key-remapping-generator as a way to create a LauchAgent to re-map using hidutil on login.)

This command will properly remap home button to escape:

 hidutil property --set '{"UserKeyMapping": [{"HIDKeyboardModifierMappingSrc": 0x0C00000223, "HIDKeyboardModifierMappingDst": 0x700000029}]}'

I saw many references to hidutil early on into my research, but spent hours finding the key code for the home button. Thanks to the code in your repo, I was finally able to find the correct Src key code. (0x0C00000223 = kHIDPage_Consumer << 32 | kHIDUsage_Csmr_ACHome)

I'm creating this issue in case it's useful to anyone else looking at the repo. I'm not necessarily suggesting that you replace your code with the line above, although you can if you want. Thank you so much again!