3 ms·
Is there a programmatic way to figure out what letter corresponds to a given keycode without that key being pressed? Because you may have to display that info s
by stkdump 6y ago
Is there a programmatic way to figure out what letter corresponds to a given keycode without that key being pressed? Because you may have to display that info somewhere to give an indication what the user has to press.
- jwalton 6y agoNot that I know of. Also, not that “alt-s” will produce an s character on a US keyboard on windows, but will not produce an s on MacOS with a US layout - alt-anything will produce all sorts of interesting characters on MacOS.
- klodolph 6y agoThere are APIs available on all major OSs that do this. Example: https://developer.apple.com/documentation/coreservices/1390584-uckeytranslate https://developer.apple.com/documentation/coreservices/13905... My memory is that if you press option E on a Mac, the translation function reports a non-zero state but no character output. You can detect this and call the translation function again with a space to get the diacritic by itself.
- klodolph 6y agoYes. You have to dig a bit to find these APIs, and they are OS-specific (and the scan codes reported by the OS are OS-specific too, even though most keyboards are USB HID these days). Here is the function for macOS: https://developer.apple.com/documentation/coreservices/1390584-uckeytranslate https://developer.apple.com/documentation/coreservices/13905...