From 62d7350d170ffa942c74ae40a99c8b0a6dcc8c95 Mon Sep 17 00:00:00 2001 From: Kim Tore Jensen Date: Mon, 1 May 2017 23:23:58 +0200 Subject: [PATCH] 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 --- key.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/key.go b/key.go index e51be97..3545215 100644 --- a/key.go +++ b/key.go @@ -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 {