Keyboard event capture in linux (wayland/KDE)

I. Problem (what I hope to achieve):

  1. timed key events (ex. rapid Space fires machine-gun, slower Space fires cannon)
  2. total keyboard capture (ex. Meta brings up MyGameOptions instead of Desktop Environment launcher like it does system wide)
  3. KeyPress and KeyRelease events (ex. modiffiers A_KeyPress && B_KeyPress && SpaceKeyRelease => FireDeathStar )

II. Background (what I kindda understood so far):

  • I'm at hello word level so... be gentle.
  • I’m on linux, wayland, KDE – not interested on other platforms for now
  • crossterm and termion are close but not there all the way for my use case - pls correct me if I'm wrong
  • Games can do it full screen, Qemu can do it in a window, so I should be able to do it in a terminal emulator window also, right?
  • I’m not doing a game (the examples are just that, examples) so struggling to understand a game engine library would be too much for me
  • Thanks in advance to anyone helping but pls be aware: any response will be followed by more, even dumber questions :wink:

You can’t generalize that. A terminal emulator window is not your window, it's a separate application, and so you do not get to fully control it.

Good call, thanks. A terminal emulator like Konsole or Alacritty is an application like any other, I kind of get that. Inside this terminal emulator application it gets a bit murky because I don’t have a clear mental image of what bash or fish could be compared to, maybe like KDE or Gnome are – different flavors of linux GUI user interface. Regardless, from Alacritty>fish I can launch many other commands/applications that go pretty deep in my system, I can launch say ls and see my files, or fdisk to f_ck up my HD, or kill and PID to see CPU processes. So, eventually I could maybe launch an application so powerful as to be able to get access to where the keystrokes live, before Wayland or KDE gets them?

PS I’ve been reading up on crossterm

and the kitty keyboard protocol,

It say that this new protocol is implemented in Alacritty and fish so I’m on the right track about Key_down, key_up, it even has a key_repeat flag. But the problem of capturing Meta before KDE does is still unclear (to me at least)