1

Where are keypresses in the terminal being handled/captured? If I want to modify the behaviour of the Alt + F# key combinations (to swithc vterms), where is this key combination being handled?

0

The console switching functions in the kernel's virtual terminal are defined in the kernel's builtin terminal emulator (drivers/tty/vt/keyboard.c in the kernel source tree) and triggered by key combinations in the kernel's keymap (drivers/tty/vt/defkeymap.map). Your system probably has this file (or one very similar) installed under /usr/share/kbd/keymaps.

If you're looking to modify the switching behavior somehow, this will entail hacking on kernel code and compiling your own patched kernel.

If all you want to do is change the key combinations, you can create your own keymap and use the loadkeys utility to install it. Start with your preferred keymap, and change the definition of the Console_N symbols (and the related Last_Console, Decr_Console, Incr_Console):

#...
keycode  59 = F1               F11              Console_13      
    control keycode  59 = F1              
    alt     keycode  59 = Console_1       
    control alt     keycode  59 = Console_1       
keycode  60 = F2               F12              Console_14      
    control keycode  60 = F2              
    alt     keycode  60 = Console_2       
    control alt     keycode  60 = Console_2
#...

Note this only affects the kernel's builtin terminal emulator, meaning only the builtin virtual console is affected. X11, Wayland, and similar contexts use XKB to achieve similar functionality. In XKB, see /usr/share/X11/xkb/compat/xfree86 for the interpreted actions, .../xkb/types/pc for the CTRL+ALT type used, and .../xkb/symbols/srvr_ctrl for the F-key definitions.

  • note this doesn't have much to do with where the input events are handled -- that takes place in the kernel's evdev module and is fairly generic (see drivers/input/... in the kernel source). – quixotic Feb 19 '18 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.