Skip to content

Commit

Permalink
Readline now correctly triggers arrow keys on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Dwyer <Brian.Dwyer@broadridge.com>
  • Loading branch information
bdwyertech committed Apr 14, 2020
1 parent e15db71 commit 9d08362
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
5 changes: 0 additions & 5 deletions keycodes.go
@@ -1,5 +1,3 @@
// +build !windows

package promptui

import "github.com/chzyer/readline"
Expand All @@ -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 = "↑"
Expand Down
10 changes: 10 additions & 0 deletions 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
)
23 changes: 2 additions & 21 deletions 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"
)

0 comments on commit 9d08362

Please sign in to comment.