Skip to content

Commit

Permalink
refactor: refine getKeyName
Browse files Browse the repository at this point in the history
  • Loading branch information
eeeXun committed Feb 22, 2024
1 parent 289605d commit e268708
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,16 @@ var keyNames = map[tcell.Key]string{
}

func getKeyName(event *tcell.EventKey) string {
var (
keyName string
key = event.Key()
)
var key = event.Key()

if key == tcell.KeyRune {
if event.Modifiers() == tcell.ModAlt {
if event.Rune() == ' ' {
keyName = "A-Space"
} else {
keyName = "A-" + string(event.Rune())
}
keyName := keyNames[key]

if event.Modifiers() == tcell.ModAlt && key == tcell.KeyRune {
if event.Rune() == ' ' {
keyName = "A-Space"
} else {
keyName = "A-" + string(event.Rune())
}
} else {
keyName = keyNames[key]
}

return keyName
Expand Down

0 comments on commit e268708

Please sign in to comment.