Skip to content

Instantly share code, notes, and snippets.

@juno
Last active January 11, 2019 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juno/05f735f71a11f22bc12f8878ffb1f5dd to your computer and use it in GitHub Desktop.
Save juno/05f735f71a11f22bc12f8878ffb1f5dd to your computer and use it in GitHub Desktop.
qmk macro definition for refocusing to page from omnibar (Chrome): https://docs.qmk.fm/#/feature_macros
diff --git a/keyboards/crkbd/keymaps/juno/keymap.c b/keyboards/crkbd/keymaps/juno/keymap.c
index 487850951..4893837e9 100644
--- a/keyboards/crkbd/keymaps/juno/keymap.c
+++ b/keyboards/crkbd/keymaps/juno/keymap.c
@@ -32,7 +32,8 @@ enum custom_keycodes {
RAISE,
ADJUST,
BACKLIT,
- RGBRST
+ RGBRST,
+ REFOCUS,
};
enum macro_keycodes {
@@ -63,6 +64,7 @@ enum macro_keycodes {
#define KC_LSES LSFT_T(KC_ESC) // Tap to ESC, Hold to Shift
#define KC_LOCK LCTL(LSFT(KC_POWER))
#define KC_SLP LGUI(LALT(KC_POWER))
+#define KC_RFC REFOCUS
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QWERTY] = LAYOUT_kc(
@@ -103,7 +105,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_ADJUST] = LAYOUT_kc(
//|----+----+----+----+----+----| |----+----+----+----+----+----|
- RST , , , , , , , , , , , ,
+ RST , , , , , , , , , , RFC, ,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
LTOG,LHUI,LSAI,LVAI, ,LOCK, , , , , , ,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
@@ -247,6 +249,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
#endif
break;
+ case REFOCUS:
+ if (record->event.pressed) {
+ // when keycode QMKBEST is pressed
+ SEND_STRING(SS_LGUI("l")); // Cmd+L
+ SEND_STRING("javascript:" SS_TAP(X_ENTER)); // "javascript:" + ENTER
+ } else {
+ // when keycode QMKBEST is released
+ }
+ return false;
+ break;
}
return true;
}
@juno
Copy link
Author

juno commented Jan 11, 2019

TIP: If you use qmk QWERTY keymap with macOS's Dvorak Input Source, you need to modify SEND_STRING arguments like this:

        SEND_STRING(SS_LGUI("p")); // Cmd+L
        SEND_STRING("ca.a;iogrkZ" SS_TAP(X_ENTER)); // "javascript:" + ENTER

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