Skip to content
Snippets Groups Projects
Commit d33e4ab4 authored by Paolo Brasolin's avatar Paolo Brasolin
Browse files

feat: #fe caps lock works on desktop

parent 029e99da
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Added
- `FE` Caps lock now works properly on desktop.
## [1.3.0] - 2022-05-18 ## [1.3.0] - 2022-05-18
### Added ### Added
......
...@@ -39,7 +39,7 @@ $key-width: 8vw; // 100/12 ~ 8.3 ...@@ -39,7 +39,7 @@ $key-width: 8vw; // 100/12 ~ 8.3
} }
&:nth-child(3) { &:nth-child(3) {
grid-template-columns: 2.333 * $key-width repeat(8, $key-width) 1fr; grid-template-columns: 2.333 * $key-width repeat(8, $key-width) 1fr;
& > :first-child { & > :nth-child(1), & > :nth-child(2) {
display: none; display: none;
} }
} }
......
...@@ -15,6 +15,7 @@ enum Key { ...@@ -15,6 +15,7 @@ enum Key {
Space = "{space}", Space = "{space}",
Enter = "{enter}", Enter = "{enter}",
Backspace = "{backspace}", Backspace = "{backspace}",
CapsLock = "{capslock}",
ShiftLeft = "{shiftleft}", ShiftLeft = "{shiftleft}",
ShiftRight = "{shiftright}", ShiftRight = "{shiftright}",
a = "a", a = "a",
...@@ -150,18 +151,19 @@ class Typewriter { ...@@ -150,18 +151,19 @@ class Typewriter {
default: [ default: [
`q w e r t z u i o p ü ${Key.Backspace}`, `q w e r t z u i o p ü ${Key.Backspace}`,
`a s d f g h j k l ö ä`, `a s d f g h j k l ö ä`,
`${Key.ShiftLeft} ${Key.ShiftRight} y x c v b n m ß ${Key.Enter}`, `${Key.CapsLock} ${Key.ShiftLeft} ${Key.ShiftRight} y x c v b n m ß ${Key.Enter}`,
], ],
shifted: [ shifted: [
`Q W E R T Z U I O P Ü ${Key.Backspace}`, `Q W E R T Z U I O P Ü ${Key.Backspace}`,
`A S D F G H J K L Ö Ä`, `A S D F G H J K L Ö Ä`,
`${Key.ShiftLeft} ${Key.ShiftRight} Y X C V B N M ẞ ${Key.Enter}`, `${Key.CapsLock} ${Key.ShiftLeft} ${Key.ShiftRight} Y X C V B N M ẞ ${Key.Enter}`,
], ],
}, },
display: { display: {
[Key.Backspace]: "", // "⌫⟵", [Key.Backspace]: "", // "⌫⟵",
[Key.Enter]: "", // "⏎↩↵⏎", [Key.Enter]: "", // "⏎↩↵⏎",
[Key.Space]: " ", // "␣", [Key.Space]: " ", // "␣",
[Key.CapsLock]: "",
[Key.ShiftLeft]: "", [Key.ShiftLeft]: "",
[Key.ShiftRight]: "", [Key.ShiftRight]: "",
}, },
...@@ -255,16 +257,26 @@ class Typewriter { ...@@ -255,16 +257,26 @@ class Typewriter {
// NOTE: this is not really disabled at event level, but events can't be triggered // NOTE: this is not really disabled at event level, but events can't be triggered
} }
toggleLayoutShift() {
const oldLayout = this.keyboard.options.layoutName;
const newLayout = oldLayout === "default" ? "shifted" : "default";
this.keyboard.setOptions({ layoutName: newLayout });
}
setShiftModeHoldable() { setShiftModeHoldable() {
this.keyboard.setOptions({ this.keyboard.setOptions({
onKeyPress: (key: string) => { onKeyPress: (key: string) => {
if (Key.ShiftLeft == key || Key.ShiftRight == key) { if (
this.keyboard.setOptions({ layoutName: "shifted" }); Key.ShiftLeft == key ||
Key.ShiftRight == key ||
Key.CapsLock == key
) {
this.toggleLayoutShift();
} }
}, },
onKeyReleased: (key: string) => { onKeyReleased: (key: string) => {
if (Key.ShiftLeft == key || Key.ShiftRight == key) { if (Key.ShiftLeft == key || Key.ShiftRight == key) {
this.keyboard.setOptions({ layoutName: "default" }); this.toggleLayoutShift();
} }
}, },
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment