diff --git a/common/web/types/src/consts/virtual-key-constants.ts b/common/web/types/src/consts/virtual-key-constants.ts index 798dd95eade..3347660f015 100644 --- a/common/web/types/src/consts/virtual-key-constants.ts +++ b/common/web/types/src/consts/virtual-key-constants.ts @@ -202,6 +202,7 @@ export const CLDRScanToUSVirtualKeyCodes = { 0x56: k.K_oE2, // << Same as 0x7D; found on iso, abnt2 0x73: k.K_oC1, 0x7D: k.K_oE2, // << Same as 0x56; found on jis + }; export type KeyMap = number[][]; diff --git a/common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts b/common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts index 252f3e43190..43429676a0a 100644 --- a/common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts +++ b/common/web/types/test/ldml-keyboard/test-ldml-keyboard-xml-reader.ts @@ -3,7 +3,7 @@ import 'mocha'; import {assert} from 'chai'; import { CommonTypesMessages } from '../../src/util/common-events.js'; import { testReaderCases } from '../helpers/reader-callback-test.js'; -import { CLDRScanToVkey, CLDRScanToKeyMap } from '../../src/consts/virtual-key-constants.js'; +import { CLDRScanToVkey, CLDRScanToKeyMap, USVirtualKeyCodes } from '../../src/consts/virtual-key-constants.js'; function pluckKeysFromKeybag(keys: LKKey[], ids: string[]) { return keys.filter(({id}) => ids.indexOf(id) !== -1); @@ -163,11 +163,20 @@ describe('check scan code routines', () => { // check all scancodes for (let scan = 0; scan <= 0xFF; scan++) { const vkey = CLDRScanToVkey(scan); - if (vkey !== undefined && vkey !== 226) { + if (vkey === undefined) { + // not mapped, which is OK + continue; + } + if (scan === 0x56 || scan === 0x7D) { + // These both can map to this scancode + assert.equal(vkey, USVirtualKeyCodes.K_oE2); + } else { + // don't check those exceptions assert.isFalse(vkeyToScan.has(vkey), - `vkey ${vkey} (other than 226) mapped from more than one scancode: ${Number(vkeyToScan.get(vkey)).toString(16)} and ${Number(scan).toString(16)}`); - vkeyToScan.set(vkey, scan); + `vkey ${vkey} mapped from more than one scancode: ${Number(vkeyToScan.get(vkey)).toString(16)} and ${Number(scan).toString(16)}`); } + // do make sure nothing else maps to that vkey + vkeyToScan.set(vkey, scan); } }); });