Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to trigger caps lock using trinket and trinketkeyboard.h #25

Open
jaredc23 opened this issue Apr 5, 2018 · 3 comments
Open

How to trigger caps lock using trinket and trinketkeyboard.h #25

jaredc23 opened this issue Apr 5, 2018 · 3 comments

Comments

@jaredc23
Copy link

jaredc23 commented Apr 5, 2018

I want to make a program that checks if the caps lock is off, then if it is it turns caps lock on. But I can't see the output of getLEDstate() and it seems to not be working. is it that I am on Mac?
I tired this: digitalWrite(LED_CAPS, (TrinketKeyboard.getLEDstate()&KB_LED_CAPS)?HIGH:LOW);
but that doesn't do anything regardless if it is on or not.

does anyone know how to check the state and turn on the caps lock via code?

@the-white-light
Copy link

the-white-light commented May 17, 2018

The LED state won't account for what happened before the USB connected, i.e. Caps/num/scroll lock must be toggled after the complete connection otherwise you won't get the state. As for how to send the keypress, that I'm not sure of either.

@samdenty
Copy link

The header files for this library don't contain aliases for all the possible keyboard HEX codes. Refer to https://gist.github.com/MightyPork/6da26e382a7ad91b5496ee55fdc73db2 for a complete list.

To press the CAPSLOCK key, simply do:

#define KEY_CAPSLOCK 0x39

TrinketKeyboard.pressKey(0, KEY_CAPSLOCK);
TrinketKeyboard.pressKey(0, 0);

@the-white-light
Copy link

Thank you @samdenty ! I had pretty much abandoned hope that there would be a way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants