Any nice way to break up key symbols?

horle

30 Jan 2015, 00:47

Hey folks!
I wonder if there is any nice way to use arbitrary symbols. As far as I know the keyboard sends a scan code that tells Windows what key is pressed. I only found scan codes for symbol groups like Kk, 1!... What if i wanted a key only have one symbol or if I wanted to have A and F share the same key.
Is there some code for each symbol as well or do I have to send Shift + kK when I press my K-only key?
I'd like to modify my ergodox firmware for more convenient programming.

Hak Foo

30 Jan 2015, 01:08

You'd probably need to send "Shift Down, K down, K up, Shift Up" to force it to emit a capital K.

Form stuff like "A and F together", you might look into layer-based programming... in layer 1, the key is A, in layer 2 it's F, and you use a key to toggle the layers.

User avatar
Halvar

30 Jan 2015, 01:16

As you said, PC keyboard protocols like PS/2 and USB HID work with key codes, not characters. The idea behind that is of course that you can define what every key does in the operating system of your PC. For Windows, there's a tool by Microsoft that lets you change your keyboard layout as you please, and there are ways to do similar things in all operating systems.

I agree it would be nice if there was a keyboard protocol that let you define all this in your keyboard and send Unicode characters and other key functions directly over the cable to the PC, so you could use your keyboard with different PCs without having to configure them. However, such a protocol was never defined, and I don't think that will happen anytime soon.

There have been some ideas about how you can approximate something like that using firmware macros with e.g. Windows ALT+numpad combinations, or like you said, sending combinations of modifiers and keys if in fact no modifier has been pressed, but none of these is really consistent except for simple cases.

User avatar
Muirium
µ

30 Jan 2015, 01:44

All true. Keyboards are actually treated as very simple devices. They send the host make and break codes: it's not even up to the keyboard to keep track of which keys are being held down. USB and PS/2 alike contain a lot of assumptions about the key map.

Changing this would allow us to make more powerful kinds of keyboards. Hard to envision what the advantage would be, though. It's a nice concept (for keyboard addicts like us) looking for a killer application.

User avatar
Eszett

30 Jan 2015, 03:46

Technically you can see it as four steps:
#1 The keyboard controller maps the physical keys (better: key adresses) to scancodes ...
#2 ... and sends these scancodes to the operating system.
#3 Then, the operating system maps the scancodes to characters ...
#4 ... and sends these characters to the application.
As you can guess, this hand-off-architecture is a problem when you want to customize. So, when you want to map a key on your keyboard to a non-standard character, then you have to use a clumsy workaround. There are three:
A) to use Alt-Codes, as Halvar said. This is the most low level method and pretty tedious to set up.
B) to change the scancode-to-character-mapping of your OS. As Halvar said. For Windows there is the “The Microsoft Keyboard Layout Creator”.
C) to use some scripting language as AutoHotkey. You can quickly setup this method, but the script has to run in the background

Personally, I use method A for special characters that I need all the time. And method C for those I only need occasionally, or just want to do a test run.

Post Reply

Return to “Keyboards”