Ubuntu – How to disable the virtual-terminal-switching shortcut keys in X

16.04keyboardshortcut-keysvirtual-consolexorg

On earlier versions of Ubuntu, the AltF☒ and Alt shortcut keys for switching between virtual terminals seem to have been disabled under X Windows, so it wasn't possible to trigger them accidentally.

I'm now using Ubuntu 16.04 with Cinnamon desktop environment, and the shortcuts are enabled even under X Windows.

I frequently trigger them accidentally while trying to access menu items or to go forwards/backwards in a web browser.

How can I disable these virtual terminal shortcut keys, or replace them with the versions that require Ctrl (e.g. CtrlAltF1 instead of just AltF1)?

(I've found several older answers that suggest a custom xmodmap, but this seems to have no effect for me.)

Best Answer

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

`