diff --git a/key_bind.go b/key_bind.go index 42669e7f..0332e27d 100644 --- a/key_bind.go +++ b/key_bind.go @@ -16,13 +16,13 @@ type ASCIICodeBind struct { } // KeyBindMode to switch a key binding flexibly. -type KeyBindMode string +type KeyBindMode uint8 const ( // CommonKeyBind is a mode without any keyboard shortcut - CommonKeyBind KeyBindMode = "common" + CommonKeyBind KeyBindMode = iota // EmacsKeyBind is a mode to use emacs-like keyboard shortcut - EmacsKeyBind KeyBindMode = "emacs" + EmacsKeyBind ) var commonKeyBindings = []KeyBind{ diff --git a/prompt.go b/prompt.go index 31a76ea8..5d6d50c8 100644 --- a/prompt.go +++ b/prompt.go @@ -247,7 +247,8 @@ func (p *Prompt) handleKeyBinding(key Key) bool { } } - if p.keyBindMode == EmacsKeyBind { + switch p.keyBindMode { + case EmacsKeyBind: for i := range emacsKeyBindings { kb := emacsKeyBindings[i] if kb.Key == key {