MCPcopy
hub / github.com/wailsapp/wails / parseKey

Function parseKey

v2/pkg/menu/keys/parser.go:13–40  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

11var namedKeys = slicer.String([]string{"backspace", "tab", "return", "enter", "escape", "left", "right", "up", "down", "space", "delete", "home", "end", "page up", "page down", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", "f32", "f33", "f34", "f35", "numlock"})
12
13func parseKey(key string) (string, bool) {
14 // Lowercase!
15 key = strings.ToLower(key)
16
17 // Check special case
18 if key == "plus" {
19 return "+", true
20 }
21
22 // Handle named keys
23 if namedKeys.Contains(key) {
24 return key, true
25 }
26
27 // Check we only have a single character
28 if len(key) != 1 {
29 return "", false
30 }
31
32 runeKey := rune(key[0])
33
34 // This may be too inclusive
35 if strconv.IsPrint(runeKey) {
36 return key, true
37 }
38
39 return "", false
40}
41
42func Parse(shortcut string) (*Accelerator, error) {
43 var result Accelerator

Callers 1

ParseFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…