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

Commit

Permalink
Temporary fix for #644 - BracketLeft key not working in Spanish (#767)
Browse files Browse the repository at this point in the history
* Add quick fix for BracketLeft issue

* Fix lint issue
  • Loading branch information
bryphe authored Oct 7, 2017
1 parent ccc67b8 commit d5d1d2d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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)

0 comments on commit d5d1d2d

Please sign in to comment.