Sending Modifier Keys w/Teensy 3.1

Status
Not open for further replies.

shooga

New member
I'm new to Teensy and have a question about USB keyboard support. I'm working through a simple project as a learning exercise and would like to use a pushbutton as my shift key. Is it possible to effectively hold the shift key with this push button and have that apply to keys pressed on another keyboard?

I've tried manually sending the modifier key using the following:

Code:
Keyboard.set_modifier(MODIFIERKEY_SHIFT);
Keyboard.send_now();

But it doesn't seem to work. Is this possible? Or are the modifier keys only applied to commands sent from Teensy and not to other keyboard devices?

Thanks!
 
Modifier keys modify the state of another key. When pressed by themselves, they do not generate events. So just pressing a modifier key does not do anything.

However, some applications (such as games) use those keys as non-modifier keys and then they do send events. Have a look in
http://www.usb.org/developers/hidpage#HID_Usage
at chapter 10, table 12 which lists the usage IDs for keys; they go up to 231. If you compare that to the list in
hardware/teensy/cores/teensy3/keylayouts.h which goes to 115. Amongst the missing ones, 224 to 231 are the modifier keys sent as regular keys. So it would be possible to add these.

However, that is just half the problem. You want to combine keyboard events from two devices and send them on as if they came from one device. You would need to write a special driver for watever platform you are using, to implement that.

In general, lots of useful information at
http://www.usb.org/developers/docs/devclass_docs/

Since you mention a simple project and a learning exercise, maybe it would help to say a bit more about what you are trying to do. What you asked about is not a simple exercise.
 
Thanks for the detailed reply. The concept is really simple (and honestly not very useful), I was going to build a foot pedal shift key. Like I said, it was more to learn than anything else.

Given what you've said about writing a special driver, I think I'll change the scope to something simpler like signing an email signature. I have the basics already working so I should be able to manage that.

Thanks again for the reply!!
 
It would be possible to make something like a foot pedal shift key (and there are cases where that might be desirable, such as an accessibility aid for someone with motor skills problems); but it would best be done by making a keyboard, with a teensy inside, which also has one or more connectors for foot pedals.
 
Status
Not open for further replies.
Back
Top