Make keyNames variable public (#144)

* Make keyNames variable public

This map of variables might be useful to applications wanting to convert text to keys, e.g. for key bindings.

* Document KeyNames variable
This commit is contained in:
Kim Tore Jensen 2017-05-01 23:23:58 +02:00 committed by Garrett D'Amore
parent e552b82b28
commit 62d7350d17
1 changed files with 4 additions and 2 deletions

6
key.go
View File

@ -78,7 +78,9 @@ func (ev *EventKey) Modifiers() ModMask {
return ev.mod
}
var keyNames = map[Key]string{
// KeyNames holds the written names of special keys. Useful to echo back a key
// name, or to look up a key from a string value.
var KeyNames = map[Key]string{
KeyEnter: "Enter",
KeyBackspace: "Backspace",
KeyTab: "Tab",
@ -218,7 +220,7 @@ func (ev *EventKey) Name() string {
}
ok := false
if s, ok = keyNames[ev.key]; !ok {
if s, ok = KeyNames[ev.key]; !ok {
if ev.key == KeyRune {
s = "Rune[" + string(ev.ch) + "]"
} else {