When you are running Raspbian without graphics (GNU bash), only in bash mode, if you press ALT+F2, ALT+F3... you switch from current tty to another.
How to make that if you press these shortcuts nothing happens? Not even switching, nothing.

Why do I need that? I have a Raspberry without screen launching a python script on launch that listen keyboard entry, I already catch all ctrl+c, ctrl+\, ctrl+Z etc. but the user can switch tty and then it's no more on the tty1 with the script running.

  • 1
    There might be a better solution. However if not, you could redefine keys. Run dumpkeys | grep -i console to see what keys manage VT switching. Read also the loadkeys and keymaps manpage.
    – VPfB
    Commented Jun 10, 2017 at 16:23
  • Hi, thanks to this link and also showkey I identified the correct keycode to disable... yet I don't understand how to disable them... I tested keymaps alt keycode 105= and many others in bash but none are working... Do you have a tips for me?
    – Jeff86
    Commented Jun 10, 2017 at 17:09

1 Answer 1


As VPfB says you can find all the key mappings that switch to the console eg with

dumpkeys | grep Console >/tmp/map

This gives a long list of keys eg:

altgr   keycode  59 = Console_13      
alt     keycode  59 = Console_1       
control alt     keycode  59 = Console_1       
altgr   keycode  60 = Console_14      

Replace the Console_* part of these with VoidSymbol:

altgr   keycode  59 = VoidSymbol
alt     keycode  59 = VoidSymbol
control alt     keycode  59 = VoidSymbol
altgr   keycode  60 = VoidSymbol

and pass the new file back into loadkeys to change the mapping

sudo loadkeys /tmp/map

You could also try just reducing the number of VTs to 1, probably in /etc/inittab for rasbian, or use the keyboard in raw mode, which is not easy as you will then have to map the key scancodes yourself.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .