Question about keyboard layouts and scancodes

StevieC

16 Sep 2020, 07:09

I've heard that the red key in this ANSI layout
keyboard-layout(3).png
keyboard-layout(3).png (14.35 KiB) Viewed 4040 times
sends the same scancode as the blue key in this ISO layout
keyboard-layout(4).png
keyboard-layout(4).png (14.86 KiB) Viewed 4040 times
and was wondering if anyone here could confirm or refute that?

User avatar
Inxie

16 Sep 2020, 14:09

Give me a second, my ThinkPad has an ISO UK keyboard.

User avatar
Inxie

16 Sep 2020, 14:17

ISO keyboard in Switch Hitter (funny how that key registers as \ in switch hitter, but is physically the one you mentioned).
Image

And my ANSI American keyboard.
Image

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

User avatar
BadCommand

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

User avatar
Inxie

16 Sep 2020, 16:28

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
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.

User avatar
BadCommand

16 Sep 2020, 19:05

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

16 Sep 2020, 23:25

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

User avatar
kps

17 Sep 2020, 00:13

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.
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.

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

17 Sep 2020, 01:23

I dual-boot my system between Windows and Linux.

StevieC

17 Sep 2020, 01:50

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.
Then what would be the proper PS/2 scancodes for these two keys to send in a board of this layout?
keyboard-layout(5).png
keyboard-layout(5).png (23.27 KiB) Viewed 3893 times

User avatar
kps

17 Sep 2020, 04:44

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

17 Sep 2020, 11:01

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?
I can confirm this for USB HID Keyboard "usage codes".

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.

User avatar
kps

17 Sep 2020, 16:42

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.
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’ [\|].

User avatar
Inxie

17 Sep 2020, 17:29

kps wrote:
17 Sep 2020, 16:42
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.
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’ [\|].
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.

StevieC

17 Sep 2020, 17:45

Is there any possibility of a workaround for this issue?

User avatar
kps

17 Sep 2020, 19:50

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.
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.
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.
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.

User avatar
kps

17 Sep 2020, 19:56

StevieC wrote:
17 Sep 2020, 17:45
Is there any possibility of a workaround for this issue?
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.

User avatar
Inxie

17 Sep 2020, 19:57

kps wrote:
17 Sep 2020, 19:50
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.
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.

User avatar
Inxie

18 Sep 2020, 01:24

kps wrote:
17 Sep 2020, 19:50
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.
Alright here we go.
Top right \| key:
Image

Bottom left hidden membrane under Shift:
Image

And the hidden hole under Shift that generates that code:
Image

Post Reply

Return to “Keyboards”