I have a small program that takes input in the form of ascii characters. I need to be able to convert these to keycodes for use with x11 functions. Is there a xlib function to do this or another library? Or will a large switch case work best?
Share
You can use
XStringToKeysymto convert at least alphanumeric characters toKeySyms, followed byXKeysymToKeycodefor conversion toKeyCodes:As @BobDoolitle pointed out in his answer, while
XStringToKeysymworks for alphanumeric single-character strings, it fails in the ASCII general case. He provides a way to trivially handle the majority of ASCII characters (0x20–0x7F) although characters outside that range require more careful treatment.