Last active
December 8, 2023 21:08
-
-
Save edykim/f41a06cc2d27a686f927d926389d3868 to your computer and use it in GitHub Desktop.
cmd + mission control key (show desktop) on QMK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // register custom keycodes | |
| enum custom_keycodes { | |
| // ... | |
| MAC_TASK, | |
| // ... | |
| }; | |
| bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |
| // ... | |
| switch (keycode) { | |
| // ... | |
| case MAC_TASK: | |
| if (record->event.pressed && get_mods() == MOD_BIT(KC_LGUI)) { | |
| unregister_code(KC_LGUI); | |
| register_code(KC_F11); | |
| wait_ms(50); | |
| unregister_code(KC_F11); | |
| register_code(KC_LGUI); | |
| } else if (record->event.pressed) { | |
| host_consumer_send(0x029F); | |
| } else { | |
| host_consumer_send(0); | |
| } | |
| return false; | |
| // ... | |
| } | |
| // ... | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I uses mission control key and cmd + mission control a lot. Mission control works with
0x029F, however, cmd +0x029Fin QMK does not work as show desktop button like Apple keyboard does. F11 is showing desktop shortcut on macOS traditionally. (Note: just pressing F11 does not trigger F11 on mac, you need to do Fn+F11 according to Apple.)The code accommodates cmd combination with mission control key. Unregistering
KC_LGUIkey needed, otherwise it will trigger cmd + F11 rather than just F11.Not sure later version of macOS keep this F11 behavior or not. If it does not work, check System Preferences > Mission Control, then what key is assigned at Show Desktop shortcut.
Note: you can use
KC_MISSION_CONTROLrather than0x029F.