How do I suppress specific keystrokes in Linux so xev does not recognize them, but the Python keyboard module does?

Viewed 54

I'm trying to suppress the input of Linux keyboard inputs temporarily for specific buttons, while still being able to read the input using the Python keyboard module (keyboard.read_key()) and subprocess module.

Simply removing the entire keyboard with terminal command 'xinput --set-prop keyboard_id Device Enabled 0' disables all keyboard inputs and terminal command 'xev' no longer recognizes these inputs. However, the Python keyboard module can still read the keys. This is what I want, however, for specific keys only.

Using xmodmap ~/.Xmod_custom, I created a custom keymap called .Xmod_custom in which which I remapped the keys to what is supposed to be nothing (simplified code with the R key mapped to nothing):

[...]

keycode  27 = 

[...]

However, xev still recognizes this keycode when I press the R key.

How would I be able to hide keyboard input from xev, while still being able to listen to it?

0 Answers
Related