Key event strings to readable/showable text. (from ZEROKEY to 0, ONEKEY to 1, etc)
*** @monster made me aware of the fact that we can’t map special keys (ä,ü, ç, etc.) so keep in mind that this is basically only useful for qwerty (us) keyboards, other keyboards will work as well, but not all keys would be recognized, due to blender can’t read out the keyboard mappings ***
def key_event_readable(key_event_name):
text_to_number = {
#keyboard
'ZEROKEY' :"0",
'ONEKEY' :"1",
'TWOKEY' :"2",
'THREEKEY' :"3",
'FOURKEY' :"4",
'FIVEKEY' :"5",
'SIXKEY' :"6",
'SEVENKEY' :"7",
'EIGHTKEY' :"8",
'NINEKEY' :"9",
'ACCENTGRAVEKEY' :"`",
'BACKSPACEKEY' :"<--",
'COMMAKEY' :",",
'EQUALKEY' :"=",
'LEFTBRACKETKEY' :"[",
'RIGHTBRACKETKEY' :"]",
'MINUSKEY' :"-",
'PERIODKEY' :".",
'SEMICOLONKEY' :";",
'SLASHKEY' :"/",
'BACKSLASHKEY' :"\\",
'QUOTEKEY' :"'",
'RETKEY' :"Return",
'PADPLUSKEY' :"Pad +",
'PADSLASHKEY' :"Pad /",
'PADASTERKEY' :"Pad *",
'PADPERIOD' :"Pad .",
'PADMINUS' :"Pad -",
#mouse
'WHEELUPMOUSE' :"Scroll up",
'WHEELDOWNMOUSE' :"Scroll down",
'LEFTMOUSE' :"LB",
'RIGHTMOUSE' :"RB",
'MIDDLEMOUSE' :"MMB"
}
if key_event_name in text_to_number:
return text_to_number[key_event_name]
elif key_event_name.endswith('KEY'):
return key_event_name[:-3]
elif key_event_name.endswith('MOUSE'):
return key_event_name[:-5]
else:
return key_event_name
(not all keys are placed inhere, like controlKey are missing etc, you can add them)