Skip to content

Instantly share code, notes, and snippets.

@edykim
Last active December 8, 2023 21:08
Show Gist options
  • Select an option

  • Save edykim/f41a06cc2d27a686f927d926389d3868 to your computer and use it in GitHub Desktop.

Select an option

Save edykim/f41a06cc2d27a686f927d926389d3868 to your computer and use it in GitHub Desktop.
cmd + mission control key (show desktop) on QMK
// 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;
// ...
}
// ...
}
@edykim
Copy link
Author

edykim commented Dec 8, 2023

I uses mission control key and cmd + mission control a lot. Mission control works with 0x029F, however, cmd + 0x029F in 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_LGUI key 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_CONTROL rather than 0x029F.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment