I spend most of my time working directly on a Linux virtual terminal without X or Wayland. I have shell key bindings for actions such as changing screen brightness, adjusting font size or volume, and limiting the CPU frequency. These bindings only work when Bash is sitting at its prompt. Once I launch something like Vim, a file manager, or a text-mode browser, the running program receives the keystrokes instead. Is there a way to capture selected key sequences globally so these actions work regardless of which terminal application is in the foreground?
4 Answers
For a quick workaround with Vim, press Ctrl+Z to suspend it and return to the shell, run the command, then use `fg` to resume Vim. It is not a global hotkey solution, but it avoids closing the editor.
Bash cannot normally see input while another foreground program owns the terminal. A practical workaround is to put the actions in standalone scripts and bind them in tmux, which can intercept keys and run commands in the background. This works well on a text-only console, although you need to configure the bindings in tmux rather than in Bash.
If you use a graphical session, desktop hotkey tools or a window manager can handle this outside Bash. Since you are mainly using virtual terminals, tmux bindings or a low-level input daemon are the more suitable approaches. Running a second shell in a tmux pane or popup is another convenient way to launch the scripts without leaving the current application.
A system-level input daemon can read keyboard events from `/dev/input/event*` and trigger commands independently of the terminal. Tools such as actkbd or similar keyboard remappers are worth investigating for a console-only setup. Be aware that reading events globally may require special permissions, and the keystroke can still reach the foreground terminal program unless the tool is able to grab the device or the key is a dedicated media/function key.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures