Show More
@@ -46,15 +46,20 b' class Keymap(dict):' | |||||
46 | else: |
|
46 | else: | |
47 | dict.__setitem__(self, key, command) |
|
47 | dict.__setitem__(self, key, command) | |
48 |
|
48 | |||
49 | def register(self, command, *keys): |
|
|||
50 | for key in keys: |
|
|||
51 | self[key] = command |
|
|||
52 |
|
||||
53 | def __getitem__(self, key): |
|
49 | def __getitem__(self, key): | |
54 | if isinstance(key, str): |
|
50 | if isinstance(key, str): | |
55 | key = ord(key) |
|
51 | key = ord(key) | |
56 | return dict.__getitem__(self, key) |
|
52 | return dict.__getitem__(self, key) | |
57 |
|
53 | |||
|
54 | def __detitem__(self, key): | |||
|
55 | if isinstance(key, str): | |||
|
56 | key = ord(key) | |||
|
57 | dict.__detitem__(self, key) | |||
|
58 | ||||
|
59 | def register(self, command, *keys): | |||
|
60 | for key in keys: | |||
|
61 | self[key] = command | |||
|
62 | ||||
58 | def get(self, key, default=None): |
|
63 | def get(self, key, default=None): | |
59 | if isinstance(key, str): |
|
64 | if isinstance(key, str): | |
60 | key = ord(key) |
|
65 | key = ord(key) |
General Comments 0
You need to be logged in to leave comments.
Login now