From e26870870ab94f9b9494e2848f5ad4b0987471ce Mon Sep 17 00:00:00 2001 From: eeeXun Date: Thu, 22 Feb 2024 14:11:39 +0800 Subject: [PATCH] refactor: refine getKeyName --- key.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/key.go b/key.go index 396dc1b..7b7a1bc 100644 --- a/key.go +++ b/key.go @@ -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