AddKey to KeyMap.
(key string, shiftedKey string, code string, keyCode int, location int)
| 27 | |
| 28 | // AddKey to KeyMap. |
| 29 | func AddKey(key string, shiftedKey string, code string, keyCode int, location int) Key { |
| 30 | if len(key) == 1 { |
| 31 | r := Key(key[0]) |
| 32 | if _, has := keyMap[r]; !has { |
| 33 | keyMap[r] = KeyInfo{key, code, keyCode, location} |
| 34 | |
| 35 | if len(shiftedKey) == 1 { |
| 36 | rs := Key(shiftedKey[0]) |
| 37 | keyMapShifted[rs] = KeyInfo{shiftedKey, code, keyCode, location} |
| 38 | keyShiftedMap[r] = rs |
| 39 | } |
| 40 | return r |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | k := Key(keyCode + (location+1)*256) |
| 45 | keyMap[k] = KeyInfo{key, code, keyCode, location} |
| 46 | |
| 47 | return k |
| 48 | } |
| 49 | |
| 50 | // Info of the key. |
| 51 | func (k Key) Info() KeyInfo { |