KeyCode figure_keycode(const char *name) { KeySym keysym; if ( (keysym = XStringToKeysym(name)) == NoSymbol) { const char *alt = 0; cerr << "Unknown key \"" << name << '\"'; // // Try to print an hint to the user. // if (strcasecmp(name, "Esc") == 0) { alt = "Escape"; } if (alt != 0) { cerr << ", perhaps you meant \"" << alt << "\"?"; } // If there was an hint available, it was printed. // Now end the message. cerr << endl; return 0; // Failure } return XKeysymToKeycode(display, keysym); }