diff --git a/keycodes.go b/keycodes.go index e084565..660c467 100644 --- a/keycodes.go +++ b/keycodes.go @@ -1,5 +1,3 @@ -// +build !windows - package promptui import "github.com/chzyer/readline" @@ -10,9 +8,6 @@ var ( // KeyEnter is the default key for submission/selection. KeyEnter rune = readline.CharEnter - // KeyBackspace is the default key for deleting input text. - KeyBackspace rune = readline.CharBackspace - // KeyPrev is the default key to go up during selection. KeyPrev rune = readline.CharPrev KeyPrevDisplay = "↑" diff --git a/keycodes_other.go b/keycodes_other.go new file mode 100644 index 0000000..789feae --- /dev/null +++ b/keycodes_other.go @@ -0,0 +1,10 @@ +// +build !windows + +package promptui + +import "github.com/chzyer/readline" + +var ( + // KeyBackspace is the default key for deleting input text. + KeyBackspace rune = readline.CharBackspace +) diff --git a/keycodes_windows.go b/keycodes_windows.go index fc29d39..737d156 100644 --- a/keycodes_windows.go +++ b/keycodes_windows.go @@ -1,29 +1,10 @@ +// +build windows + package promptui // source: https://msdn.microsoft.com/en-us/library/aa243025(v=vs.60).aspx var ( - // KeyEnter is the default key for submission/selection inside a command line prompt. - KeyEnter rune = 13 - // KeyBackspace is the default key for deleting input text inside a command line prompt. KeyBackspace rune = 8 - - // FIXME: keys below are not triggered by readline, not working on Windows - - // KeyPrev is the default key to go up during selection inside a command line prompt. - KeyPrev rune = 38 - KeyPrevDisplay = "k" - - // KeyNext is the default key to go down during selection inside a command line prompt. - KeyNext rune = 40 - KeyNextDisplay = "j" - - // KeyBackward is the default key to page up during selection inside a command line prompt. - KeyBackward rune = 37 - KeyBackwardDisplay = "h" - - // KeyForward is the default key to page down during selection inside a command line prompt. - KeyForward rune = 39 - KeyForwardDisplay = "l" )