Created
October 9, 2020 20:59
-
-
Save gedankenexperimenter/491fe51e77b22923c5835ae4ff242bc8 to your computer and use it in GitHub Desktop.
Custom Kaleidoscope Plugin for `alt`+`A` to switch apps (on macOS)
This file contains 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
namespace kaleidoscope { | |
namespace plugin { | |
class AppSwitcher : public kaleidoscope::Plugin { | |
public: | |
static constexpr KeyAddr invalid_addr{KeyAddr::invalid_state}; | |
AppSwitcher() {} | |
EventHandlerResult onKeyswitchEvent(Key &key, | |
KeyAddr key_addr, | |
uint8_t key_state) { | |
if (keyToggledOn(key_state)) { | |
if (key == Key_LeftAlt) { | |
alt_key_addr_ = key_addr; | |
} else if (key == Key_A && alt_key_addr_ != invalid_addr) { | |
// release `alt` | |
handleKeyswitchEvent(Key_NoKey, alt_key_addr_, WAS_PRESSED); | |
// press `gui` | |
handleKeyswitchEvent(Key_LeftGui, alt_key_addr_, IS_PRESSED); | |
key = Key_Tab; | |
alt_key_addr_ = invalid_addr; | |
} | |
} | |
return EventHandlerResult::OK; | |
} | |
private: | |
KeyAddr alt_key_addr_; | |
}; | |
} // namespace plugin | |
} // namespace kaleidoscope | |
kaleidoscope::plugin::AppSwitcher AppSwitcher; | |
KALEIDOSCOPE_INIT_PLUGINS( | |
Appswitcher, … | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment