diff --git a/README.md b/README.md index 3fd74a7..40fe710 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ A golang wrapper for parsing gocui keybindings. ```go // get a single keybinding keybinding.Parse("ctrl+c") +keybinding.Parse("/") +keybinding.Parse("ü") +keybinding.Parse("ö") // get a list of keybindings keybinding.ParseAll("ctrl+A, ctrl+B, CTRL+ALT+C") diff --git a/keybinding.go b/keybinding.go index 7384a08..415363e 100644 --- a/keybinding.go +++ b/keybinding.go @@ -127,9 +127,9 @@ func Parse(input string) (Key, error) { f := func(c rune) bool { return unicode.IsSpace(c) || c == '+' } tokens := strings.FieldsFunc(input, f) - if len(tokens) == 1 && len(tokens[0]) == 1 { - single := rune(tokens[0][0]) - if unicode.IsLetter(single) { + if len(tokens) == 1 && len([]rune(tokens[0])) == 1 { + single := []rune(tokens[0])[0] + if unicode.IsPrint(single) { return Key{single, gocui.ModNone, tokens}, nil } } diff --git a/keybinding_test.go b/keybinding_test.go index 269736d..412f3af 100644 --- a/keybinding_test.go +++ b/keybinding_test.go @@ -36,6 +36,9 @@ func TestParse(t *testing.T) { {"ctrl + alt + !", 0, gocui.ModAlt, "unsupported keybinding: KeyCtrl! (+1)"}, {"q", rune('q'), gocui.ModNone, ""}, {" q", rune('q'), gocui.ModNone, ""}, + {"ü", rune('ü'), gocui.ModNone, ""}, + {"ö", rune('ö'), gocui.ModNone, ""}, + {"/", rune('/'), gocui.ModNone, ""}, } for idx, trial := range table {