Keyboard stroke "CTRL+Q"

Dear all,

I am sorry for my stupid question. I hope you can forgive me.

I have an Arduino Uno on which I have tried to use the "Keyboard()" command.
After searching a bit, I have found that this is not possible with Uno, but with a 32u4 microcontroller (Arduino® Board ATmega 32u4, Arduino® Leonardo).

In my case, I need to have an Arduino which emulates the "CTRL+Q" sequence on a keyboard.
As I would press it manually.

According to my knowledge, CTRL+Q is:

17 Dec
11 Hex
DC1 Char

I could use the method Keyboard.write() (press and release the button, Keyboard.press() keeps the button pressed).

Keyboard.write(17);
Keyboard.write('DC1');
Keyboard.write(11);

Is that correct?
Which board do you suggest to me? (Board ATmega 32u4, and Leonardo have almost the same price, here in Germany).

You said...

That's mean below.

Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(`q`);
Keyboard.releaseAll();

Keyboard.write() is one tap! It's released soon as press.
If use write(), means just press them in order, not at the same time.


Although it is not an official board, I recommend Pro micro.
It is the smaller Leonardo.

Hi Chris,

therefore I shall have understood wrongly. I was thinking that the complete sequence "CTRL+Q" is equivalent to 17 in the decimal system, 11 in Hexadecimal, DC1 in char.
And I was thinking that, since the Keyboard.write() method takes either a Dec or Hex or Char as argument, I could have used it.

The Keyboard.write() doesn't send ASCII characters. It translates ASCII characters into the keycodes of the US-EN keyboard that have the character on it. It can also control the Shift so it can pick either character on the key. Anything that is not a character that appears on the US-EN keyboard has to be done with multiple keystrokes.

NOTE: The Keyboard library assumes your OS is set to the US-EN keyboard layout. If the 'Q' on your keyboard is on a different key than on the US-EN keyboard, use the character on the key in the same position. For example, on the French (AZERTY) keyboard the A and Q are swapped. To get a "Ctrl-Q" you would have to use:

Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(`a`);   // 'q' key on French layout
Keyboard.releaseAll();

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.