I'm working with wxPython, the Python bridge to wxWidgets, so I guess a wxWidgets user could reply. I'm playing with the KeyEvent
class and since I'm testing my code on other platforms and other keyboards, I've made an incredible (to me) discovery: other keyboard layouts don't seem to be very well supported.
Here's what I mean: if you run the demo (KeyEvents.py
in my case) and press on random letters, with a QWERTY keyboard, everything works. Switch to another layout, things still work... somewhat. Right now I have an AZERTY keyboard mostly used in France, so when I press the a key (which is on the English position of the q) a 'a' is reported. So far so good. But if I press a é (a key which is on the English 2 key), a 2 is reported. Reading the documentation didn't exactly help me to figure out what is going on. Is that a kind of mistake no one has noticed since wx is out? I would guess and hope not, but better late than never I guess.
To be more technical still, the KeyDown
and KeyUp
events have this problem. I have an AZERTY kleyboard, I press on the 2 key, and a 2 is reported, whereas a é is written on screen. Admittedly, the Char
event does report a é, but, if I understood correctly, a Char
event is not triggered in any context a KeyDown
event is triggered. Perhaps I missed something here and perhaps that's the solution for me and international users.
Thanks in advance for your reply,
Char event is not triggered in any context a KeyDown event is triggered.
False.
Due to each country has its own keyboard layout, wxWidgets sends two events when a key is pressed: One (key event) is the somewhat hardware code for that key; the other (char event) is the "translated" code, normally a Unicode point, but an ASCII code if you disabled Unicode support.
Keyevent is useful if you just want to do something on key-down or key-up events. If working with chars, then use only char event.
wxWidgets docs about wxKeyEvent at https://docs.wxwidgets.org/trunk/classwx_key_event.html