Skip to content

Commit 06f604d

Browse files
committed
Add fr-FR keyboard layout
1 parent e3c141d commit 06f604d

File tree

4 files changed

+180
-2
lines changed

4 files changed

+180
-2
lines changed

packages/keyboard/src/layouts/en-US.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ export const EN_US: IKeyboardLayout = new KeycodeLayout(
136136
222: "'",
137137
224: 'Meta' // firefox
138138
},
139-
// TODO: Figure out Ctrl vs Control
140-
[...MODIFIER_KEYS, 'Ctrl'],
139+
MODIFIER_KEYS,
141140
{
142141
AltLeft: 'Alt',
143142
AltRight: 'Alt',
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
import { IKeyboardLayout, KeycodeLayout } from '../core';
5+
6+
import { MODIFIER_KEYS } from '../special-keys';
7+
8+
/**
9+
* A code-based keyboard layout for a common Norwegian keyboard.
10+
*
11+
* Note that this does not include Apple's magic Keyboards, as they map
12+
* the keys next to the Enter key differently (BracketRight and
13+
* Backslash on en-US).
14+
*/
15+
export const FR_FR: IKeyboardLayout = new KeycodeLayout(
16+
'fr-FR',
17+
{},
18+
MODIFIER_KEYS,
19+
{
20+
AltLeft: "Alt",
21+
AltRight: "AltGraph",
22+
ArrowDown: "ArrowDown",
23+
ArrowLeft: "ArrowLeft",
24+
ArrowRight: "ArrowRight",
25+
ArrowUp: "ArrowUp",
26+
Backquote: "²",
27+
Backslash: "*",
28+
Backspace: "Backspace",
29+
BracketRight: "$",
30+
Comma: ";",
31+
ControlLeft: "Control",
32+
ControlRight: "Control",
33+
Delete: "Delete",
34+
Digit0: "À",
35+
Digit1: "&",
36+
Digit2: "É",
37+
Digit3: '"',
38+
Digit4: "'",
39+
Digit5: "(",
40+
Digit6: "-",
41+
Digit7: "È",
42+
Digit8: "_",
43+
Digit9: "Ç",
44+
End: "End",
45+
Enter: "Enter",
46+
Equal: "=",
47+
Escape: "Escape",
48+
F1: "F1",
49+
F10: "F10",
50+
F11: "F11",
51+
F12: "F12",
52+
F2: "F2",
53+
F3: "F3",
54+
F4: "F4",
55+
F5: "F5",
56+
F6: "F6",
57+
F7: "F7",
58+
F8: "F8",
59+
F9: "F9",
60+
Home: "Home",
61+
Insert: "Insert",
62+
IntlBackslash: "<",
63+
KeyA: "Q",
64+
KeyB: "B",
65+
KeyC: "C",
66+
KeyD: "D",
67+
KeyE: "E",
68+
KeyF: "F",
69+
KeyG: "G",
70+
KeyH: "H",
71+
KeyI: "I",
72+
KeyJ: "J",
73+
KeyK: "K",
74+
KeyL: "L",
75+
KeyM: ",",
76+
KeyN: "N",
77+
KeyO: "O",
78+
KeyP: "P",
79+
KeyQ: "A",
80+
KeyR: "R",
81+
KeyS: "S",
82+
KeyT: "T",
83+
KeyU: "U",
84+
KeyV: "V",
85+
KeyW: "Z",
86+
KeyX: "X",
87+
KeyY: "Y",
88+
KeyZ: "W",
89+
Minus: ")",
90+
Numpad0: "0",
91+
Numpad1: "1",
92+
Numpad2: "2",
93+
Numpad3: "3",
94+
Numpad4: "4",
95+
Numpad5: "5",
96+
Numpad6: "6",
97+
Numpad7: "7",
98+
Numpad8: "8",
99+
Numpad9: "9",
100+
NumpadAdd: "+",
101+
NumpadDecimal: ".",
102+
NumpadDivide: "/",
103+
NumpadEnter: "Enter",
104+
NumpadMultiply: "*",
105+
NumpadSubtract: "-",
106+
PageDown: "PageDown",
107+
PageUp: "PageUp",
108+
Period: ":",
109+
Quote: "Ù",
110+
ScrollLock: "ScrollLock",
111+
Semicolon: "M",
112+
ShiftLeft: "Shift",
113+
ShiftRight: "Shift",
114+
Slash: "!",
115+
Tab: "Tab"
116+
}
117+
);

packages/keyboard/src/layouts/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
export { EN_US } from './en-US';
5+
export { FR_FR } from './fr-FR';
56
export { NB_NO } from './nb-NO';

packages/keyboard/tests/src/index.spec.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import { expect } from 'chai';
1111

1212
import {
1313
EN_US,
14+
FR_FR,
1415
getKeyboardLayout,
1516
KeycodeLayout,
17+
NB_NO,
1618
setKeyboardLayout
1719
} from '@lumino/keyboard';
1820

@@ -192,4 +194,63 @@ describe('@lumino/keyboard', () => {
192194
expect(EN_US.isModifierKey('Meta')).to.equal(true);
193195
});
194196
});
197+
198+
describe('FR_FR', () => {
199+
it('should be a keycode layout', () => {
200+
expect(FR_FR).to.be.an.instanceof(KeycodeLayout);
201+
});
202+
203+
it('should have standardized keys', () => {
204+
expect(FR_FR.isValidKey('A')).to.equal(true);
205+
expect(FR_FR.isValidKey('Z')).to.equal(true);
206+
expect(FR_FR.isValidKey('0')).to.equal(true);
207+
expect(FR_FR.isValidKey('a')).to.equal(false);
208+
expect(FR_FR.isValidKey('Ù')).to.equal(true);
209+
});
210+
211+
it('should have modifier keys', () => {
212+
expect(FR_FR.isValidKey('Shift')).to.equal(true);
213+
expect(FR_FR.isValidKey('Control')).to.equal(true);
214+
expect(FR_FR.isValidKey('Alt')).to.equal(true);
215+
expect(NB_NO.isValidKey('AltGraph')).to.equal(true);
216+
expect(FR_FR.isValidKey('Meta')).to.equal(true);
217+
});
218+
219+
it('should correctly detect modifier keys', () => {
220+
expect(FR_FR.isModifierKey('Shift')).to.equal(true);
221+
expect(FR_FR.isModifierKey('Control')).to.equal(true);
222+
expect(FR_FR.isModifierKey('Alt')).to.equal(true);
223+
expect(FR_FR.isModifierKey('Meta')).to.equal(true);
224+
});
225+
});
226+
227+
describe('NB_NO', () => {
228+
it('should be a keycode layout', () => {
229+
expect(NB_NO).to.be.an.instanceof(KeycodeLayout);
230+
});
231+
232+
it('should have standardized keys', () => {
233+
expect(NB_NO.isValidKey('A')).to.equal(true);
234+
expect(NB_NO.isValidKey('Z')).to.equal(true);
235+
expect(NB_NO.isValidKey('0')).to.equal(true);
236+
expect(NB_NO.isValidKey('a')).to.equal(false);
237+
expect(NB_NO.isValidKey('Æ')).to.equal(true);
238+
});
239+
240+
it('should have modifier keys', () => {
241+
expect(NB_NO.isValidKey('Shift')).to.equal(true);
242+
expect(NB_NO.isValidKey('Control')).to.equal(true);
243+
expect(NB_NO.isValidKey('Alt')).to.equal(true);
244+
expect(NB_NO.isValidKey('AltGraph')).to.equal(true);
245+
expect(NB_NO.isValidKey('Meta')).to.equal(true);
246+
});
247+
248+
it('should correctly detect modifier keys', () => {
249+
expect(NB_NO.isModifierKey('Shift')).to.equal(true);
250+
expect(NB_NO.isModifierKey('Control')).to.equal(true);
251+
expect(NB_NO.isModifierKey('Alt')).to.equal(true);
252+
expect(NB_NO.isModifierKey('AltGraph')).to.equal(true);
253+
expect(NB_NO.isModifierKey('Meta')).to.equal(true);
254+
});
255+
});
195256
});

0 commit comments

Comments
 (0)