Open DarkFenX opened 4 years ago
Also ran into this problem. Solution is possible at least under wxGTK, where you have raw x11 key codes returned by GetRawKeyFlags(). You have to get raw x11 key code, and then determine keycode value through the x11 api. Here is example in C, maybe the same approach is possible in Python.
#include <xkbcommon/xkbcommon.h>
// ...
auto key_code = event.GetKeyCode();
#if defined (__WXGTK__)
if (key_code == 0) {
xkb_context *ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
struct xkb_rule_names names = {
.rules = NULL,
.model = NULL,
.layout = "us",
.variant = NULL,
.options = NULL
};
xkb_keymap *keymap = xkb_keymap_new_from_names(ctx, &names, XKB_KEYMAP_COMPILE_NO_FLAGS);
xkb_state *state = xkb_state_new(keymap);
xkb_keycode_t keycode = GetRawKeyFlags();
char key_code_str[64];
xkb_state_key_get_utf8(state, keycode, key_code_str, sizeof(key_code_str));
key_code = toupper(key_code_str[0]);
xkb_state_unref(state);
xkb_keymap_unref(keymap);
xkb_context_unref(ctx);
}
#endif
Affects both xorg and wayland.
Operating system: Debian Linux wxPython version & source: 4.0.6 from debian repos Python version & source: 3.7 from debian repos
Description of the problem: Gnome 3, latin layout: when you press "A" key, code 65 is printed. With non-latin layout (e.g. russian), code 0 is printed.
Example is stolen from #1144