Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Refactor to work with HasPrefix
Browse files Browse the repository at this point in the history
Resolves: #326 (comment)
  • Loading branch information
ankur22 committed Aug 2, 2022
1 parent 463edde commit fb56fc9
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions common/keyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (k *Keyboard) keyDefinitionFromKey(key keyboardlayout.KeyInput) keyboardlay
// e.g. `Control`.
// When a key such as `2` is pressed, we must ignore shift
// otherwise we would type `@`.
isKeyXOrOnShiftLayerAndShiftUsed := (isKeyX(string(key)) || foundInShift) &&
isKeyXOrOnShiftLayerAndShiftUsed := (strings.HasPrefix(string(key), "Key") || foundInShift) &&
shift != 0 &&
srcKeyDef.ShiftKey != ""
if isKeyXOrOnShiftLayerAndShiftUsed {
Expand All @@ -250,39 +250,6 @@ func (k *Keyboard) keyDefinitionFromKey(key keyboardlayout.KeyInput) keyboardlay
return keyDef
}

func isKeyX(key string) bool {
_, ok := map[string]interface{}{
"KeyA": nil,
"KeyB": nil,
"KeyC": nil,
"KeyD": nil,
"KeyE": nil,
"KeyF": nil,
"KeyG": nil,
"KeyH": nil,
"KeyI": nil,
"KeyJ": nil,
"KeyK": nil,
"KeyL": nil,
"KeyM": nil,
"KeyN": nil,
"KeyO": nil,
"KeyP": nil,
"KeyQ": nil,
"KeyR": nil,
"KeyS": nil,
"KeyT": nil,
"KeyU": nil,
"KeyV": nil,
"KeyW": nil,
"KeyX": nil,
"KeyY": nil,
"KeyZ": nil,
}[key]

return ok
}

func (k *Keyboard) modifierBitFromKeyName(key string) int64 {
switch key {
case "Alt":
Expand Down

0 comments on commit fb56fc9

Please sign in to comment.