Typing the Keypad Enter with the Keyboard Library

I've done ample searches and trials, but I can't seem to figure out how to have the Keyboard Library type the keypad enter key that is on the right side of extended keyboards, as opposed to the normal enter (return on Mac keyboards) that is above the right shift key.

Can this be done? What am I missing? Thanks!

Keyboard.println() might send what you want.

Keyboard.write() is your other chance.

Enter key should send a newline ('\n' == 10) or carriage return ('\r'==13) or '\r' followed by '\n'.

Thanks. I’ve tried all this with no success. Any other ideas?

I don't understand what you're trying to do then.
I look at the Keyboard library and it's like HID serial.

If it's a matter of taking input from an Arduino keypad and outputting through the Keyboard library then your code needs to read the keypad and translate when that one key is pressed.

Thanks for the response. Here's what I'm trying to do:

I'm not using an Arduino keypad. I use a set of switches and an Arduino Leonardo as an alternative keyboard for myself. (I'm actually using it to type these posts.)

I use Mac OS X, and in some applications, the keypad enter has a different meaning then the normal enter/return. (For example, in AppleScript Editor, the keypad enter means Compile, while return takes you to a new line of text.)

So, I want to figure out how to have the Leonardo send the keypad enter to the computer. I tried Keyboard.println(), which gave me a new line, Keyboard.write(10), which gave me a new line, Keyboard.write(13), which didn't give me anything, and Keyboard.print("\r\n"), which gave me a new line.

If you look on page 55 of http://www.usb.org/developers/devclass_docs/Hut1_11.pdf you'll see the keypad enter is HID code 88. How do I have the Leonardo send that to the computer?

Thanks!

The library won't let you do all unprintables, it says, but there are special keys here:

and a link to the Keyboard.press() command.

Did you figure it out?
Am having the same problem..
Am trying to automatically login and logout of my PC.
I couldnt find key for enter or windows as KEY_RETURN is not working in my laptop and KEY_LEFT_GUI is not working for windows..

any suggestions..

I was looking for an answer and got here, but I realized it takes a few seconds to test them all. Hardest part, find a text editor that does nothing, code editors ‘help’ by indenting newlines which you don’t want. I used TextEdit on Mac and Preferences> Plain text. Based on Keyboard.write() documentation

int ascii = 0;

void setup() {
  pinMode(2, INPUT_PULLUP);
  Keyboard.begin();
}

void loop() {
  if(digitalRead(2)==LOW){
    for (ascii=0;ascii<128;ascii++) {
       Keyboard.write(ascii);
       Keyboard.println( String(ascii) );
       delay(10);
    }
  }
}

Press a button attached between pin2 and ground, and watch every character printed before the code used to send it. There is no formatting or spacing on purpose as that would defeat the purpose. For example the line with ,44 printed “,” with Keyboard.write(44). Try a loop testing different modifier key presses. Keyboard.press() with modifiers

Keyboard.write(176);

Works fine for me as std. return button. However, I didn't try NumPad Enter.

weiglt:
Keyboard.write(176);

Works fine for me as std. return button. However, I didn't try NumPad Enter.

Thanks.
Also worked this code to send ENTER ascii code with HID devices to the windows PC :

Keyboard.press(176);

Bumped on request from someone who has new information.

1 Like

Keypad Enter is USB keycode 88 (0x58) but to get it through the Keyboard library unmapped you have to add 136 to it (0-127 is ascii and 128-135 are the 8 ctrl/shift/meta/option keys).

After adding 136 you get 224 (0xE0). Use that with Keyboard.press() and Keyboard.release(), or Keyboard.write().

1 Like