Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Temporary fix for #644 - BracketLeft key not working in Spanish #767

Merged
merged 2 commits into from
Oct 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion browser/src/Input/Keyboard/KeyboardLayout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Event, IEvent } from "./../../Event"
import * as Log from "./../../Log"
import * as Platform from "./../../Platform"

export interface IKeyMap {
[key: string]: IKeyInfo
Expand All @@ -12,6 +13,23 @@ export interface IKeyInfo {
withAltGraph?: string
}

// Helper method to augment the key mapping in cases
// where it isn't accurate from `keyboard-layout`
const augmentKeyMap = (keyMap: IKeyMap, language: string): IKeyMap => {

// Temporary hack to workaround atom/keyboard-layout#36
if (Platform.isWindows() && language === "es-ES") {
keyMap["BracketLeft"] = { // tslint:disable-line no-string-literal
unmodified: null,
withShift: null,
withAltGraph: "[",
withAltGraphShift: null,
}
}

return keyMap
}

class KeyboardLayoutManager {
private _keyMap: IKeyMap = null
private _onKeyMapChanged: Event<void> = new Event<void>()
Expand All @@ -27,8 +45,9 @@ class KeyboardLayoutManager {
public getCurrentKeyMap(): IKeyMap {
if (!this._keyMap) {
const KeyboardLayout = require("keyboard-layout") // tslint:disable-line no-var-requires
const keyboardLanguage = KeyboardLayout.getCurrentKeyboardLanguage()
Log.verbose("[Keyboard Layout] " + KeyboardLayout.getCurrentKeyboardLayout())
this._keyMap = KeyboardLayout.getCurrentKeymap()
this._keyMap = augmentKeyMap(KeyboardLayout.getCurrentKeymap(), keyboardLanguage)

// Lazily subscribe to the KeyboardLayout.onDidChangeCurrentKeyboardLayout
// This is lazy primarily for unit testing outside of electron (where this module isn't available)
Expand Down
3 changes: 2 additions & 1 deletion test/Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Ideally, these test cases could be automated to minimize overhead with the relea
- ß (AltGr+S)
- Dead key in normal mode - navigate to mark (ma, `+space+a)
- Dead key on command line

- Spanish:
- [ Left bracket (AltGr+[ on Windows es-ES)