How to create a macro like typing Space then OSM(LeftShift) with OneShot plugin

How to create a macro like typing Space then OSM(LeftShift) with OneShot plugin

I tried some stuffs like

  • OneShot.inject in a macro
  • OneShot.inject isPressed , wasPessed in a macro
  • MacroDown (Space, OSM(LeftShift));

Nevertheless nothing works like I want (do nothing or do some weird behaviour).

The goal is to have some direct keys like :
Space + OSM(LeftShift)
Return + OSM(LeftShift)
. + Space + OSM(LeftShift)
in order not to type shift key when previous key is a space, return or point then space for i

If someone how to do that or some ideas to try, I’m interested. Don’t hesitate to ask more explanation if it is not clear.

Thanks in advance

I ended up doing this with leader sequences instead, with leader + letter outputting full stop, space, capital of that letter. Here is the code, it’s just for full stop space capitalise, but it should be easy to adapt to your other cases with some search and replace. I included a leader + space sequence that doesn’t output a letter at all for when a non-capital starts the sentence, like “iPhone” or numbers or symbols. I made the leader time-out quite large for my own preference, others might not like it that high.

#include “Kaleidoscope-Leader.h”

// somewhere in keymap - LEAD(0)

static void leaderFSA(uint8_t seq_index) {
Macros.type(PSTR(". A"));
static void leaderFSB(uint8_t seq_index) {
Macros.type(PSTR(". B"));
static void leaderFSC(uint8_t seq_index) {
Macros.type(PSTR(". C"));
static void leaderFSD(uint8_t seq_index) {
Macros.type(PSTR(". D"));
static void leaderFSE(uint8_t seq_index) {
Macros.type(PSTR(". E"));
static void leaderFSF(uint8_t seq_index) {
Macros.type(PSTR(". F"));
static void leaderFSG(uint8_t seq_index) {
Macros.type(PSTR(". G"));
static void leaderFSH(uint8_t seq_index) {
Macros.type(PSTR(". H"));
static void leaderFSI(uint8_t seq_index) {
Macros.type(PSTR(". I"));
static void leaderFSJ(uint8_t seq_index) {
Macros.type(PSTR(". J"));
static void leaderFSK(uint8_t seq_index) {
Macros.type(PSTR(". K"));
static void leaderFSL(uint8_t seq_index) {
Macros.type(PSTR(". L"));
static void leaderFSM(uint8_t seq_index) {
Macros.type(PSTR(". M"));
static void leaderFSN(uint8_t seq_index) {
Macros.type(PSTR(". N"));
static void leaderFSO(uint8_t seq_index) {
Macros.type(PSTR(". O"));
static void leaderFSP(uint8_t seq_index) {
Macros.type(PSTR(". P"));
static void leaderFSQ(uint8_t seq_index) {
Macros.type(PSTR(". Q"));
static void leaderFSR(uint8_t seq_index) {
Macros.type(PSTR(". R"));
static void leaderFSS(uint8_t seq_index) {
Macros.type(PSTR(". S"));
static void leaderFST(uint8_t seq_index) {
Macros.type(PSTR(". T"));
static void leaderFSU(uint8_t seq_index) {
Macros.type(PSTR(". U"));
static void leaderFSV(uint8_t seq_index) {
Macros.type(PSTR(". V"));
static void leaderFSW(uint8_t seq_index) {
Macros.type(PSTR(". W"));
static void leaderFSX(uint8_t seq_index) {
Macros.type(PSTR(". X"));
static void leaderFSY(uint8_t seq_index) {
Macros.type(PSTR(". Y"));
static void leaderFSZ(uint8_t seq_index) {
Macros.type(PSTR(". Z"));
static void leaderFS(uint8_t seq_index) {
Macros.type(PSTR(". "));

static const kaleidoscope::Leader::dictionary_t leader_dictionary[] PROGMEM =
{LEADER_SEQ(LEAD(0), Key_B), leaderFSB},
{LEADER_SEQ(LEAD(0), Key_C), leaderFSC},
{LEADER_SEQ(LEAD(0), Key_D), leaderFSD},
{LEADER_SEQ(LEAD(0), Key_E), leaderFSE},
{LEADER_SEQ(LEAD(0), Key_F), leaderFSF},
{LEADER_SEQ(LEAD(0), Key_G), leaderFSG},
{LEADER_SEQ(LEAD(0), Key_H), leaderFSH},
{LEADER_SEQ(LEAD(0), Key_I), leaderFSI},
{LEADER_SEQ(LEAD(0), Key_J), leaderFSJ},
{LEADER_SEQ(LEAD(0), Key_K), leaderFSK},
{LEADER_SEQ(LEAD(0), Key_L), leaderFSL},
{LEADER_SEQ(LEAD(0), Key_M), leaderFSM},
{LEADER_SEQ(LEAD(0), Key_N), leaderFSN},
{LEADER_SEQ(LEAD(0), Key_O), leaderFSO},
{LEADER_SEQ(LEAD(0), Key_P), leaderFSP},
{LEADER_SEQ(LEAD(0), Key_Q), leaderFSQ},
{LEADER_SEQ(LEAD(0), Key_R), leaderFSR},
{LEADER_SEQ(LEAD(0), Key_S), leaderFSS},
{LEADER_SEQ(LEAD(0), Key_T), leaderFST},
{LEADER_SEQ(LEAD(0), Key_U), leaderFSU},
{LEADER_SEQ(LEAD(0), Key_V), leaderFSV},
{LEADER_SEQ(LEAD(0), Key_W), leaderFSW},
{LEADER_SEQ(LEAD(0), Key_X), leaderFSX},
{LEADER_SEQ(LEAD(0), Key_Y), leaderFSY},
{LEADER_SEQ(LEAD(0), Key_Z), leaderFSZ},
{LEADER_SEQ(LEAD(0), Key_Spacebar), leaderFS});



void setup() {


Leader.dictionary = leader_dictionary;
Leader.time_out = 5000;

The only unfortunate thing is that you have to complete the leader key release before the letter’s keypress. Other than that, it works like a dream! You might also want to include something like when leader is pressed twice, it just outputs a full stop: I just use full stop on another layer personally.

I also use that leader key as a qukey, where held down, it is shift. I find it a very intuitive setup, but I guess it all depends if you usually use Shift on the right hand (since almost everyone is used to full stop on the right hand from QWERTY).

Awesome. I did not realize I can do it with leader sequences. I will try it.
Thank you very much.

1 Like

Not a problem, I’m glad someone else can benefit from it!

One thing I notice using this code: I have to release the keypress of the key ending the sequence before typing the next letter. This may not be an issue for others, but I’m realizing just how hard it can be for me to avoid this on letter combinations that I tend to roll. I wonder if that is a bug or just the way leader keys have been implemented.

Yes, that bugs me as well - @algernon is aware of the issue I believe, and it is on his long long list of things to do. I’ve managed to change my habits temporarily to avoid it, but I hope I can resume some time not having to worry about depressing keys like that.

Actually, it’s a bit of an annoyance for me in general - it seems like several plugins are set up with a key-release mentality rather than the more natural-feeling key-down. Perhaps something to think about.

1 Like

I think I’m going to try putting commonly-rolled sequences in my dictionary. Ex: {LEAD(0), Key T, Key H, leaderFSTH}

That might cut down on it.

Edit: weird behavior results from one sequence being contained within the other sequence