Here’s a little plugin that you can add to your sketch to do this:
namespace kaleidoscope {
namespace plugin {
// Plugin that converts `ctrl`+`j` to `ctrl`+`left arrow` and `ctrl`+`l` to
// `ctrl`+`right arrow`.
class CtrlJLArrows : public Plugin {
public:
EventHandlerResult onKeyEvent(KeyEvent &event) {
// We only care about events where `j` or `l` toggles on, so return `OK`
// immediately in all other cases.
if (!keyToggledOn(event.state) ||
(event.key != Key_J && event.key != Key_L))
return EventHandlerResult::OK;
// Search `live_keys` for an active `ctrl` key.
bool ctrl_active = false;
for (Key key : live_keys.all()) {
if (key == Key_LeftControl || key == Key_RightControl) {
ctrl_active = true;
break;
}
}
// If we found an active `ctrl` key, replace the `j` or `l` with an arrow.
if (ctrl_active) {
if (event.key == Key_J) {
event.key = Key_LeftArrow;
} else {
event.key = Key_RightArrow;
}
}
return EventHandlerResult::OK;
}
};
} // namespace plugin
} // namespace kaleidoscoope
kaleidoscope::plugin::CtrlJLArrows CtrlJLArrows;
KALEIDOSCOPE_INIT_PLUGINS(CtrlJLArrows);
You would also include any other plugins that you’re using in the call to KALEIDOSCOPE_INIT_PLUGINS()
, with CtrlJLArrows
somewhere near the bottom of the list.