Question about keyboard layouts and scancodes
- Inxie
- Location: United States
- Main keyboard: IBM Model F XT
- Main mouse: Lenovo Legion M500
- Favorite switch: Buckling Spring
- DT Pro Member: -
ISO keyboard in Switch Hitter (funny how that key registers as \ in switch hitter, but is physically the one you mentioned).

And my ANSI American keyboard.

BIOS scan code is the same, but the HID scan code is different.

And my ANSI American keyboard.

BIOS scan code is the same, but the HID scan code is different.
- BadCommand
- Location: USA - CA
- Main keyboard: IBM Model F AT
- Main mouse: CST
- Favorite switch: capacitive buckling spring
2B is shared by both of those physical locations (and they are functionally the same). Of course, that depends on the scan code set - much more info to be found in John J. G. Savard's article: http://quadibloc.com/comp/scan.htm
- Inxie
- Location: United States
- Main keyboard: IBM Model F XT
- Main mouse: Lenovo Legion M500
- Favorite switch: Buckling Spring
- DT Pro Member: -
Though, interestingly enough, if I use "gzdoom", and set the / key on my UK laptop, and copy that game over to my desktop with the American keyboard, the / doesn't register. I have to rebind it. But then it's incompatible with the UK laptop.BadCommand wrote: 16 Sep 2020, 16:07 2B is shared by both of those physical locations (and they are functionally the same). Of course, that depends on the scan code set - much more info to be found in John J. G. Savard's article: http://quadibloc.com/comp/scan.htm
But for 99.99% of the time, it's identical, 2B. But on that .01%, they are different.
- BadCommand
- Location: USA - CA
- Main keyboard: IBM Model F AT
- Main mouse: CST
- Favorite switch: capacitive buckling spring
Do you mean the /? or \| key (to the right of left shift) on the UK layout? If \|, that's probably because that key doesn't exist on the US layout. Never mind that the IBM PC initially placed it there...
-
StevieC
- Location: United States
- Main keyboard: Laptop
- Main mouse: Kensington ExpertMouse
- Favorite switch: Hall-effect
I mean the key between '" and Enter on an ISO keyboard (it appears to be the ~# key on the UK 'board. I'm trying to figure out whether a keyboard that combines all the "key-splits" of ANSI, ISO, JIS, and even Brazil's ABNT keyboard standard (which bisects the plus-key on a Windows computer's numpad) could still conform to standard PS/2 scancodes without needing any keys to share a scancode
- kps
- Location: Waterloo, Ontario, Canada
- Main keyboard: Kinesis contoured
- Main mouse: Kensington Slimblade trackball
- DT Pro Member: -
The PS/2 scan codes are different in principle, but many keyboards actually send the [\|] code for the key between ['"] and [Return], because it's semantically the equivalent key, and manufacturers don't want to have different firmware for different regions.Inxie wrote: 16 Sep 2020, 16:28 Though, interestingly enough, if I use "gzdoom", and set the / key on my UK laptop, and copy that game over to my desktop with the American keyboard, the / doesn't register. I have to rebind it. But then it's incompatible with the UK laptop.
But for 99.99% of the time, it's identical, 2B. But on that .01%, they are different.
If your desktop has a USB keyboard, it's similar: a USB keyboard might send HID 07:0032 ‘Keyboard Non-US # and ~’ for the key between ['"] and [Return]), or more commonly it might send HID 07:0031 ‘Keyboard \ and |’. In any case a USB keyboard doesn't send PS/2 ‘scancodes’ and what you see is the result of some mapping that your OS pulled out of its ass.
It sounds like one of your systems actually distinguishes the two keys and the other doesn't.
Last edited by kps on 17 Sep 2020, 04:21, edited 1 time in total.
-
StevieC
- Location: United States
- Main keyboard: Laptop
- Main mouse: Kensington ExpertMouse
- Favorite switch: Hall-effect
Then what would be the proper PS/2 scancodes for these two keys to send in a board of this layout?kps wrote: 17 Sep 2020, 00:13 many keyboards actually send the [\|] code for the key between ['"] and [Return], because it's semantically the equivalent key, and manufacturers don't want to have different firmware for different regions.
- kps
- Location: Waterloo, Ontario, Canada
- Main keyboard: Kinesis contoured
- Main mouse: Kensington Slimblade trackball
- DT Pro Member: -
Since you mentioned ‘2B’, I assume that by ‘scancodes’ you mean Windows codes. Those are based on IBM Set 1 scan codes from the IBM PC, which only had one format so it didn't need a way to distinguish them. Even if you have a keyboard that does distinguish them (e.g. USB or PS/2 Set 3 scan codes), Windows will smash the difference and report ‘scancode’ 0x2B for both.
-
Findecanor
- Location: Stockholm, Sweden
- DT Pro Member: 0011
I can confirm this for USB HID Keyboard "usage codes".StevieC wrote: 16 Sep 2020, 07:09 I've heard that the red key in this ANSI layoutkeyboard-layout(3).png sends the same scancode as the blue key in this ISO layoutkeyboard-layout(4).png and was wondering if anyone here could confirm or refute that?
There is actually a dedicated "usage code" in the USB HID standard for the ISO layout's key (blue) but nobody uses it. Every OS uses the same code as in ANSI.
I did once make my keyboard send that code, but it didn't work in Linux or MS-Windows.
- kps
- Location: Waterloo, Ontario, Canada
- Main keyboard: Kinesis contoured
- Main mouse: Kensington Slimblade trackball
- DT Pro Member: -
Interesting. It should work in Windows according to MS docs and it should work in Linux according to source — but it will be treated just like ‘normal’ [\|].Findecanor wrote: 17 Sep 2020, 11:01 I did once make my keyboard send that code, but it didn't work in Linux or MS-Windows.
- Inxie
- Location: United States
- Main keyboard: IBM Model F XT
- Main mouse: Lenovo Legion M500
- Favorite switch: Buckling Spring
- DT Pro Member: -
If this is what I think, I have a Unicomp M122, it is the model with the ANSI/ISO hybrid (\| in on the right but with vertical enter, and long shift on the left), and I popped the shift and found that the membrane was still there despite no spring or plunger. Pressing it ALSO generated \|, just like the other key. This was on Windows. So my M122 technically has two \| keys which generate different USB scancodes (just like my gzdoom, that key hidden under shift would not respond to the same bindings as the other \| key), but Windows treated them both the same in nearly every program I used.kps wrote: 17 Sep 2020, 16:42Interesting. It should work in Windows according to MS docs and it should work in Linux according to source — but it will be treated just like ‘normal’ [\|].Findecanor wrote: 17 Sep 2020, 11:01 I did once make my keyboard send that code, but it didn't work in Linux or MS-Windows.
- kps
- Location: Waterloo, Ontario, Canada
- Main keyboard: Kinesis contoured
- Main mouse: Kensington Slimblade trackball
- DT Pro Member: -
I'm curious — can you tell that the keyboard actually sent different USB codes (e.g. with USBPcap)? My IBM M122 uses Set 3 and sends different code, but presumably the Unicomp PS/2 M122 uses Set 2 and doesn't.Inxie wrote: 17 Sep 2020, 17:29 at I think, I have a Unicomp M122, it is the model with the ANSI/ISO hybrid (\| in on the right but with vertical enter, and long shift on the left), and I popped the shift and found that the membrane was still there despite no spring or plunger. Pressing it ALSO generated \|, just like the other key. This was on Windows.
The key beside left shift is completely different, even in the Windows scancode set (0x56). It just happens to be mapped to \| in some layouts.So my M122 technically has two \| keys which generate different USB scancodes (just like my gzdoom, that key hidden under shift would not respond to the same bindings as the other \| key), but Windows treated them both the same in nearly every program I used.
- kps
- Location: Waterloo, Ontario, Canada
- Main keyboard: Kinesis contoured
- Main mouse: Kensington Slimblade trackball
- DT Pro Member: -
What's the issue? If you're building a keyboard and want both physical keys, I'd probably make one of them 07:0089 ‘Keyboard International 3’ and map it to your taste in your layouts.
- Inxie
- Location: United States
- Main keyboard: IBM Model F XT
- Main mouse: Lenovo Legion M500
- Favorite switch: Buckling Spring
- DT Pro Member: -
I will have to get back to you at least after 6pm EST (or am I in EDT now? I lost track), my mother is working from home and she's using the M122 currently.
- Inxie
- Location: United States
- Main keyboard: IBM Model F XT
- Main mouse: Lenovo Legion M500
- Favorite switch: Buckling Spring
- DT Pro Member: -
Alright here we go.
Top right \| key:

Bottom left hidden membrane under Shift:

And the hidden hole under Shift that generates that code:
