Pressing ctrl + enter as keyboard

I'm using an STM32F103 BluePill board with STM32duino as an input device. With it, I'm trying to press control and then enter at the same time (with control as the modifier key) to use a keyboard shortcut (in Gmail). It is not working - any idea what could be the cause of this?

I've tried all of the following:

modKey('\n', KEY_LEFT_CTRL); modKey(KEY_RETURN, KEY_LEFT_CTRL); modKey(10, KEY_LEFT_CTRL); modKey(13, KEY_LEFT_CTRL);

modKey('\n', KEY_RIGHT_CTRL); modKey(KEY_RETURN, KEY_RIGHT_CTRL); modKey(10, KEY_RIGHT_CTRL); modKey(13, KEY_RIGHT_CTRL);

void modKey(char key, int mod) { Keyboard.press(mod); delay(200); Keyboard.press(key); delay(200); Keyboard.releaseAll(); delay(200); }

Doing:

modKey(10, KEY_LEFT_GUI);

or any of the other variations above DOES produce the keyboard shortcut I would expect for Windows+Enter pressed at the same time, so I'm confused why Ctrl+Enter is failing here.

jayjones:
I’m using an STM32F103 BluePill board with STM32duino as an input device. With it, I’m trying to press control and then enter at the same time (with control as the modifier key) to use a keyboard shortcut (in Gmail). It is not working - any idea what could be the cause of this?

I’ve tried all of the following:

modKey(’\n’, KEY_LEFT_CTRL);
modKey(KEY_RETURN, KEY_LEFT_CTRL);
modKey(10, KEY_LEFT_CTRL);
modKey(13, KEY_LEFT_CTRL);

modKey(’\n’, KEY_RIGHT_CTRL);
modKey(KEY_RETURN, KEY_RIGHT_CTRL);
modKey(10, KEY_RIGHT_CTRL);
modKey(13, KEY_RIGHT_CTRL);

void modKey(char key, int mod)
{
Keyboard.press(mod);
delay(200);
Keyboard.press(key);
delay(200);
Keyboard.releaseAll();
delay(200);
}

Doing:

modKey(10, KEY_LEFT_GUI);

or any of the other variations above DOES produce the keyboard shortcut I would expect for Windows+Enter pressed at the same time, so I’m confused why Ctrl+Enter is failing here.

Just a guess here:

When you press ANY key on a PC, it send a “key pressed” code and later a “key released” code when released.

Now, something like “CTRL-ENTER” is not a “special code”, Rather it’s the computer detecting that “CTRL” was pressed and then when “ENTER” is pressed, the computer asks “OK I got ENTER, now is anything else pressed? Ah yes CTRL is also down, so send a CTRL-ENTER”.

If you send both CTRL and ENTER “keys” at the same instant, the computer may miss the “CTRL” before it evaluates the “ENTER”.

Try sending them separately, with maybe a millisecond or two of delay in between, like this:

Send CTRL
delay (1)
Send ENTER

That may work… hope this helps.

Thanks for your reply. Yes, there's a delay - I use the modkey function above:

void modKey(char key, int mod) { Keyboard.press(mod); delay(200); Keyboard.press(key); delay(200); Keyboard.releaseAll(); delay(200); }