Skip to content

Commit

Permalink
Merge pull request #145 from bdwyertech/bdwyertech
Browse files Browse the repository at this point in the history
Use the same keycodes cross-platform
  • Loading branch information
jbowes authored Sep 28, 2020
2 parents 0ce406e + fd5822c commit 5c05132
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 26 deletions.
5 changes: 0 additions & 5 deletions keycodes.go
Original file line number Diff line number Diff line change
@@ -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

// KeyCtrlH is the key for deleting input text.
KeyCtrlH rune = readline.CharCtrlH

Expand Down
10 changes: 10 additions & 0 deletions keycodes_other.go
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 5c05132

Please sign in to comment.