SparkFun Forums 

Where electronics enthusiasts find answers.

#205483
I'm fairly new . . .

I used the SparkFun sample Keyboard HID code for Pro Micro 5v - it works on my local computer.

But when that computer is connected to another via Remote Desktop - then characters typed are often of the incorrect case. Specifically it seems capitals randomly get changed to their lower case versions.

I only seemed to happen if the characters were capitalized - it would show them remotely as Lower Case - sometimes.

Any characters that were lower case always remained lower case.

For example :
Only4Royce14! [ correct ]
May show as :
only4Royce14!
only4royce141
Only4royce14!

Any combination of the O, R or ! randomly being toggled to its lower case version.

I ideas ? [ I added a bunch of delays to try to fix, but no joy. ]

Here's the code :

/* HID KeyBoard Example
by: Jim Lindblom
date: 1/12/2012
license: MIT License - Feel free to use this code for any purpose.
No restrictions. Just keep this license if you go on to use this
code in your future endeavors! Reuse and share.

This is very simplistic code that allows you to send a 'z' with
a momentary pushbutton.
*/

#include <Keyboard.h>
int buttonPin = 9; // Set a button to any pin

void setup()
{
pinMode(buttonPin, INPUT); // Set the button as an input
digitalWrite(buttonPin, HIGH); // Pull the button high
}

void loop()
{
if (digitalRead(buttonPin) == 0) // if the button goes low
{
delay(150);
Keyboard.write(79); // send an 'O' to the computer via Keyboard HID
// Here I'm even trying ASCII, but with the same random lower case results.
delay(150);
Keyboard.write('n'); // send a 'z' to the computer via Keyboard HID
delay(50);
Keyboard.write('l'); // send a 'z' to the computer via Keyboard HID
delay(50);
Keyboard.write('y'); // send a 'z' to the computer via Keyboard HID
delay(50);
Keyboard.write('4'); // send a 'z' to the computer via Keyboard HID
delay(150);
Keyboard.write(82); // send an 'R' to the computer via Keyboard HID
delay(150);
Keyboard.write('o'); // send a 'z' to the computer via Keyboard HID
delay(50);
Keyboard.write('y'); // send a 'z' to the computer via Keyboard HID
delay(50);
Keyboard.write('c'); // send a 'z' to the computer via Keyboard HID
delay(50);
Keyboard.write('e'); // send a 'z' to the computer via Keyboard HID
delay(50);
Keyboard.write('1'); // send a 'z' to the computer via Keyboard HID
delay(50);
Keyboard.write('4'); // send a 'z' to the computer via Keyboard HID
delay(150);
Keyboard.write(33); // send a '!' to the computer via Keyboard HID
delay(150);
delay(1000); // delay so there aren't a kajillion z's
}
}


When I manually type to the remote computer - there are never case problems.

Thank you
#205497
Hello, and thanks for posting!

The Arduino library that handles HID keyboard silently presses shift then the letter you're typing to make a capitol letter. My guess is that your remote host is polling the keyboard too quickly to catch that shift has been 'pressed' when you try to type a capitol letter or a punctuation that needs shift pressed.

You might try coding in shift presses and pass the lower case letter you're wanting to send to see if that does the trick. Check the library for the Keyboard.press() and Keyboard.release() commands. I think if you do a Keyboard.press(KEY_LEFT_SHIFT) then pause a moment followed by a Keyboard.write('o') and then a Keyboard.releaseAll(), that might do the trick for you to consistently get the letter O rather than o.