Add key_shortname function.
authorMatthijs Kooijman <matthijs@stdin.nl>
Tue, 3 Nov 2009 14:11:47 +0000 (15:11 +0100)
committerMatthijs Kooijman <matthijs@stdin.nl>
Tue, 3 Nov 2009 14:11:47 +0000 (15:11 +0100)
This function contains code previously in another class.

src/gui/gui.py

index cf9536b79f7a3496a173af2ea22332b5a55d306a..a07091b3fb06126b37812e7770ab2b4f746041f9 100644 (file)
@@ -68,6 +68,15 @@ def get_key(key_name):
         key=eval('EKey%s'%key_name)
     return key
 
+def key_shortname(key_name):
+    """ Find the one-character name for a key """
+    if not key_name:
+        return None
+    elif key_name == 'Backspace':
+        return 'C'
+    else:
+        return key_name
+
 def all_key_names():
     return filter(lambda entry:entry[0:4]=='EKey',dir(key_codes))
 def all_key_values():