How can I disable the virtual-terminal-switching shortcut keys in X?

Solution 1:

For a permanent fix, you can add your modified mapping to /etc/console-setup/remap.inc.

You must run sudo dpkg-reconfigure console-setup -phigh to apply the changes and reboot.

For example, this what I use to disable alt-Fxx and alt arrow switching

# Remap alt+Fxx key to void to avoid terminal switching
alt     keycode  59 = VoidSymbol
alt     keycode  60 = VoidSymbol
alt     keycode  61 = VoidSymbol
alt     keycode  62 = VoidSymbol
alt     keycode  63 = VoidSymbol
alt     keycode  64 = VoidSymbol
alt     keycode  65 = VoidSymbol
alt     keycode  66 = VoidSymbol
alt     keycode  67 = VoidSymbol
alt     keycode  68 = VoidSymbol
# Also remove mapping for alt left arrow and right arrow
alt keycode 105 = VoidSymbol
alt keycode 106 = VoidSymbol

`

Solution 2:

Try to use the command in terminal sudo kbd_mode -s and see if it helps. It changes keyboard input mode to "scancode". I had the same issue and found that this may be the solution.

Solution 3:

This thread at Unix stackexchange helped me figure out a temporary one-off solution:

# This command removes all the lines that look like:
#    alt keycode 123 = Console_1'
# ... with no additional modifiers
$ sudo dumpkeys | grep -Pv '^\s+alt(gr)?\s+keycode\s+\d+\s+=\s+(Console_|Incr_Console|Decr_Console)'|sudo loadkeys

It seems that Ubuntu 16.04's console-setup package stores its cached keymap at /etc/console-setup/cached.kmap.gz.

But I can't figure out what program generates this "cache" in the first place. Any ideas? All I can tell is that re-running dpkg-reconfigure console-setup console-setup-linux triggers its regeneration.