Skip to content

Commit 026bdfa

Browse files
committed
Fixed the Norwegian layout and compact # scancode
1 parent 7076f2f commit 026bdfa

3 files changed

Lines changed: 29 additions & 27 deletions

File tree

internal/keyboard/keyboard_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ var compactScancodeTests = []struct {
313313
{"CapsLock", 0, 3, 1.75, 1, hidCapsLock},
314314
{"A", 1.75, 3, 1, 1, hidA},
315315
{"Enter (compact)", 12.75, 3, 2.25, 1, hidEnter},
316+
{"Hash (ISO compact)", 12.75, 3, 1, 1, hidHash}, // narrow key at same x = hash, not enter
316317
{"LShift", 0, 4, 2.25, 1, hidLShift},
317318
{"Z", 2.25, 4, 1, 1, hidZ},
318319
{"RShift", 12.25, 4, 2.75, 1, hidRShift},

internal/keyboard/layouts/nb_NO.kle.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@
4444
"d": true,
4545
"w": 4
4646
},
47-
"nb-NO\nNorsk bokmål\n(ISO 105)\n"
47+
"Norsk bokmål\nnb-NO\n\n(ISO 105)"
4848
],
4949
[
5050
{
5151
"y": 0.5
5252
},
53-
"|\n§",
54-
"1\n!",
55-
"2\n\"\n@\n",
56-
"3\n#\n£\n",
57-
"4\n¤\n$\n",
58-
"5\n%\n\n",
59-
"6\n&",
60-
"7\n/\n{\n",
61-
"8\n(\n[\n",
62-
"9\n)\n]\n",
63-
"0\n=\n}\n",
64-
"+\n?",
65-
"\\\n`\n´\n",
53+
"§\n|",
54+
"!\n1",
55+
"\"\n2\n\n@",
56+
"#\n3\n\n£",
57+
"¤\n4\n\n$",
58+
"%\n5\n\n",
59+
"&\n6",
60+
"/\n7\n\n{",
61+
"(\n8\n\n[",
62+
")\n9\n\n]",
63+
"=\n0\n\n}",
64+
"?\n+",
65+
"`\n\\\n\n´",
6666
{
6767
"w": 2
6868
},
@@ -96,8 +96,8 @@
9696
"i",
9797
"o",
9898
"p",
99-
"å\nÅ",
100-
"¨\n^\n~\n",
99+
"Å\nå",
100+
"^\n¨\n\n~",
101101
{
102102
"x": 0.25,
103103
"w": 1.25,
@@ -144,9 +144,9 @@
144144
"j",
145145
"k",
146146
"l",
147-
"ø\nØ",
148-
"æ\nÆ",
149-
"'\n*",
147+
"Ø\nø",
148+
"Æ\næ",
149+
"*\n'",
150150
{
151151
"x": 4.75
152152
},
@@ -162,17 +162,17 @@
162162
"w": 1.25
163163
},
164164
"⇧ Shift",
165-
"<\n>",
165+
">\n<",
166166
"z",
167167
"x",
168168
"c",
169169
"v",
170170
"b",
171171
"n",
172172
"m",
173-
",\n;",
174-
".\n:",
175-
"-\n_",
173+
";\n,",
174+
":\n.",
175+
"_\n-",
176176
{
177177
"w": 2.75
178178
},

internal/keyboard/scancode.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,11 @@ func inferScancodeWithTable(x, y, w, h float64, table map[int][]posEntry) uint8
462462
return hidEnter
463463
}
464464

465-
// ISO hash key (#/~): on ISO layouts, the key at x≈12.75 on the home row
466-
// is the hash key (narrow, w=1), not Enter (wide, w≥2). ANSI Enter at the
467-
// same position is wider (w=2.25) and caught by the table entry.
468-
if approxEq(x, 12.75) && w < 1.5 && math.Round(y) == 4 {
465+
// ISO hash key (#/~): on ISO layouts, the narrow key at x≈12.75 on the
466+
// home row is the hash key (w≈1), not Enter (w≥2). The width check alone
467+
// distinguishes them — no row index check needed, so this works for both
468+
// full-size (home row at y≈3.5→4) and compact (home row at y=3) tables.
469+
if approxEq(x, 12.75) && w < 1.5 {
469470
return hidHash
470471
}
471472

0 commit comments

Comments
 (0)