Go Down

Topic: Keyboard Shift-Ctrl-ESC Key Codes (Read 371 times) previous topic - next topic

kartal2_ocal

Hi

I'm Making a Keyboard from Arduino But I couldn't write the codes of Shift-Ctrl-ESC keys.

Can you help me?


#include "Keyboard.h"

//Define pines.
const int LEFT_SHIFT_KEY = 3;       // Press SHIFT


void setup() {
  // put your setup code here, to run once:

 pinMode(3, INPUT_PULLUP);   // Activa resistencia pullup en entrada.
  Keyboard.begin();                         // Iniciamos emulacion teclado.
  delay (500);
}

void loop() {
  // put your main code here, to run repeatedly:

int estadoPulsador = digitalRead(3);
                                                                             
  if (digitalRead(3) == 1)                   // if the SHIFT Button is pressed
  {                                             
  Keyboard.press('Shift');
  delay(100);
  Keyboard.releaseAll();
  // wait for new window to open:
  delay(100);
  }
}

pert

I think if you study this reference page, and the example code on that page, it will be clear how to do it:
https://www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardpress/
If you're still stuck after that, come back with your updated code and a detailed description of what you're having trouble with.


Please use code tags when you post code or warning/error messages. To do this, click the </> button on the forum toolbar, then paste the text you want to be in the code tags. Finally, move the cursor out of the code tags before adding any additional text you don't want to be in the code tags. If your browser doesn't show the posting toolbar, then you can manually add the code tags like this:
[code]// your code is here[/code]

The reason for doing this is that, without code tags, the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier for us to read your code and to copy it to the IDE or editor.

Using code tags and other important information is explained in the "How to use this forum" post. Please read it.

Go Up