0

The basic problem is this: I have a mini keyboard I'm using for a Raspberry Pi project, and since there is only one shift, ctrl and alt key apiece, that means combinations on the left side of the keyboard like shift-A and ctrl-C are kind of awkward to pull off without dropping it.

My intended solution is to add a separate button to simulate a second shift key. With the RPi and some very basic electronics and programming experience, this is fairly simple in theory. At least for most keys. But since the shift key is kind of a "modifier" key...

The question is, do Operating Systems handle each keypress separately or is it the keyboard's job to send a capital A when the user pushes shift-A? Can I use a second input to simulate a shift key and then push the A key on the keyboard to have the Operating System print a capital A? A general answer is appreciated, but if it depends on the Operating System, the OS in question is Raspbian Stretch, based on Debian Stretch.

1 Answer 1

3

Most modern keyboards are interfaced as USB HID devices; there are exceptions, but your case with a raspberry pi is clearly USB.

In the case of a USB keyboard, the state of modifier keys is communicated by a separate bitmask of states sent along when reporting ordinary keys, see for example https://wiki.osdev.org/USB_Human_Interface_Devices for the specific bits and keys. (This is different from PS/2 keyboards, where modifier keys had their own scan codes).

If you can find the code which interprets events and understand how it uses the modifier bits, you could modify the logic to look at other things as well. You could also potentially just bitwise OR in your own alternate input states on top of the reported modifier keys (since a "1" indicates a pressed key).

For some simpler type of keyboards using keyswitches, you might also be able to wire in a separate pushbutton in parallel with an existing modifier key; but this could be tricky.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .