diff --git a/option.go b/option.go index abce19a..0352d37 100644 --- a/option.go +++ b/option.go @@ -206,6 +206,14 @@ func OptionSwitchKeyBindMode(m KeyBindMode) Option { } } +// OptionCompletionOnDown allows for Down arrow key to trigger completion. +func OptionCompletionOnDown() Option { + return func(p *Prompt) error { + p.completionOnDown = true + return nil + } +} + // SwitchKeyBindMode to set a key bind mode. // Deprecated: Please use OptionSwitchKeyBindMode. var SwitchKeyBindMode = OptionSwitchKeyBindMode diff --git a/prompt.go b/prompt.go index 4e3ef43..e910a29 100644 --- a/prompt.go +++ b/prompt.go @@ -25,6 +25,7 @@ type Prompt struct { keyBindings []KeyBind ASCIICodeBindings []ASCIICodeBind keyBindMode KeyBindMode + completionOnDown bool } // Exec is the struct contains user input context. @@ -148,7 +149,7 @@ func (p *Prompt) feed(b []byte) (shouldExit bool, exec *Exec) { func (p *Prompt) handleCompletionKeyBinding(key Key, completing bool) { switch key { case Down: - if completing { + if completing || p.completionOnDown { p.completion.Next() } case Tab, ControlI: