Skip to content

Commit 9d08362

Browse files
committed
Readline now correctly triggers arrow keys on Windows
Signed-off-by: Brian Dwyer <[email protected]>
1 parent e15db71 commit 9d08362

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

keycodes.go

-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build !windows
2-
31
package promptui
42

53
import "github.com/chzyer/readline"
@@ -10,9 +8,6 @@ var (
108
// KeyEnter is the default key for submission/selection.
119
KeyEnter rune = readline.CharEnter
1210

13-
// KeyBackspace is the default key for deleting input text.
14-
KeyBackspace rune = readline.CharBackspace
15-
1611
// KeyPrev is the default key to go up during selection.
1712
KeyPrev rune = readline.CharPrev
1813
KeyPrevDisplay = "↑"

keycodes_other.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// +build !windows
2+
3+
package promptui
4+
5+
import "github.com/chzyer/readline"
6+
7+
var (
8+
// KeyBackspace is the default key for deleting input text.
9+
KeyBackspace rune = readline.CharBackspace
10+
)

keycodes_windows.go

+2-21
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
1+
// +build windows
2+
13
package promptui
24

35
// source: https://msdn.microsoft.com/en-us/library/aa243025(v=vs.60).aspx
46

57
var (
6-
// KeyEnter is the default key for submission/selection inside a command line prompt.
7-
KeyEnter rune = 13
8-
98
// KeyBackspace is the default key for deleting input text inside a command line prompt.
109
KeyBackspace rune = 8
11-
12-
// FIXME: keys below are not triggered by readline, not working on Windows
13-
14-
// KeyPrev is the default key to go up during selection inside a command line prompt.
15-
KeyPrev rune = 38
16-
KeyPrevDisplay = "k"
17-
18-
// KeyNext is the default key to go down during selection inside a command line prompt.
19-
KeyNext rune = 40
20-
KeyNextDisplay = "j"
21-
22-
// KeyBackward is the default key to page up during selection inside a command line prompt.
23-
KeyBackward rune = 37
24-
KeyBackwardDisplay = "h"
25-
26-
// KeyForward is the default key to page down during selection inside a command line prompt.
27-
KeyForward rune = 39
28-
KeyForwardDisplay = "l"
2910
)

0 commit comments

Comments
 (0)