75

Since yesterday Alt+F4 is working unexpectedly on my computer. When I press those keys TTY4 is opened. Also, the application which is running on the GUI receives the Alt+F4 message. This is solved by rebooting the system, but after a while it starts doing this again.

As far as I have googled there are other people finding this problem but with no solutions (1, 2).

I am running Ubuntu Gnome 16.10, Kernel version 4.8.0-39-generic and GNOME Shell version 3.20.4.

ig343
  • 1,008
  • 2
  • 10
  • 16
  • Did you try the answer from the [second post you linked](http://askubuntu.com/questions/801313/problems-with-tty-and-altf4)? – M. Becerra Feb 23 '17 at 17:42
  • You might want to check out this question : http://askubuntu.com/questions/123493/screen-went-black – Dimitri Markovich Feb 23 '17 at 17:49
  • @M.Becerra I don't have the package console-cyrillic installed on my system. – ig343 Feb 24 '17 at 03:39
  • 3
    @DimitriMarkovich I did not hit Ctrl+Alt+F4, I am absolutely sure it's Alt+F4 which is doing what Ctrl+Alt+F4 should do. – ig343 Feb 24 '17 at 03:40
  • Is your CTRL key physically stuck? Jiggle the key and turn your keyboard upside down to clear potential crumbs. – Sam Gleske Feb 24 '17 at 07:30
  • Absolutely sure it's not. It is a software problem. When I reboot the pc it goes back to normal. – ig343 Feb 25 '17 at 23:24
  • On Xenial, same problem (using Gnome) – rcomblen Feb 27 '17 at 08:31
  • same problem, also on Ubuntu Gnome - Ubuntu 16.04.2 LTS 64 bits - GNOME Shell 3.18.5 - Linux 4.4.0-64-generic – maxlath Mar 05 '17 at 23:28
  • This had stopped in the last two weeks but now it is happening again. – ig343 Mar 21 '17 at 20:16
  • You are using a laptop or a desktop? if it's a laptop, add the FN key – Egon Stetmann. Mar 22 '17 at 21:17
  • It is a laptop. What do you mean by "add the fn key"? – ig343 Mar 22 '17 at 23:35
  • I faced the same problem right after upgrading some packages like: grub, linux-header, linux-image v4.4.0-21, etc. All combinations (Alt + F[1-6]) go to respective TTY; Alt+F7 go back to graphical session (but logged out). Solutions? – Matt Mello Apr 08 '17 at 20:54
  • dont forget to use the function key – Egon Stetmann. Jun 26 '17 at 05:55
  • 1
    it seems related to a kernel upgrade, and it happens on other Linux distros: https://unix.stackexchange.com/questions/59949/centos-avoid-that-alt-f4-switches-to-console – elias Jul 10 '17 at 14:25
  • I only wanted to find out where I suddenly was, somehow dropped into that since I hit a bit of the *Alt* button as well while pressing *Alt+F4*, and this question helped me finding out that this is the tty, so that I could search further how to get back to my screen without entering the login, see [How can I leave tty?](https://askubuntu.com/questions/393160/how-can-i-leave-tty). – questionto42 Oct 25 '22 at 17:54

4 Answers4

112

I had this recently on Ubuntu GNOME and on Unity. The answer is this:

sudo kbd_mode -s

Run that in a terminal and then the Alt+F4 keyboard combination returns to normal.

From kbd_mode man page (from kbd project and package):

kbd_mode - report or set the keyboard mode

Without argument, kbd_mode prints the current keyboard mode (RAW, MEDIUMRAW or XLATE).
With argument, it sets the keyboard mode as indicated:

-s: scancode mode (RAW),

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
popey
  • 22,629
  • 9
  • 71
  • 123
  • 6
    Running `sudo kbd_mode` before the above command showed me that my keyboard was in “Unicode (UTF-8) mode”. The above command will set your keyboard mode to “raw (scancode) mode”, as [`man kbd_mode`](https://linux.die.net/man/1/kbd_mode) can verify. – Rory O'Kane Jul 31 '18 at 22:26
  • 3
    Just for future reference for others, this works in 18.04 as well (it uses GNOME by default). – jhpratt Sep 06 '18 at 01:16
  • 2
    And sudo kbd_mode -u to switch back to unicode mode – WitchCraft Sep 08 '18 at 05:35
  • 5
    It is really annoying to have to do this for every boot, apparently a permanent solution is to edit /etc/console-setup/remap.inc as described by https://askubuntu.com/a/1059609/104605 . – Compholio Oct 04 '18 at 14:26
1
  1. As root, edit /etc/console-setup/remap.inc.

  2. Add this line at the bottom:

    alt     keycode  62 = VoidSymbol
    
  3. Run sudo dpkg-reconfigure console-setup -phigh

  4. Reboot (reboot).

The problem should be fixed now. At least it worked for me.

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Nicolas Raoul
  • 11,473
  • 27
  • 93
  • 149
-3

Things to do

1. Alt + f1 

- what will above do? Will it open TTY1?

2. open terminal and just press "j" without quote

what is the output? will it work same as pressing enter key? or just prints "j"?

In the link you posted @Pielco11 says sudo update-grub solves the problem.

Also try sudo apt-get update

Prakash
  • 158
  • 1
  • 1
  • 9
  • When this happens, Alt+F1 opens TTY1. I haven't tried pressing J on a terminal specifically but I know that other commands using Ctrl work fine. – ig343 Mar 26 '17 at 16:52
  • can you confirm what will happen if you just press "j" in terminal? Open terminal with ctrl + Atl +T – Prakash Mar 27 '17 at 05:19
  • I tried what you asked and it just prints "j". – ig343 Apr 05 '17 at 15:51
-4

Some ideas to trace down and maybe fix the issue:

  • Booting with a Live-CD in order to check if the problem is physical
  • Use another keyboard
  • Switch the keyboard layout or try to remap the Ctrl
  • Does it only happen on the desktop environment or does it also switch to TTY4 if you are at some other TTY? If it happens also on the TTYs, it might be related to some kernel parameter.

Did you try the tip on the last comment of your second reference (update-grub)?

Julen Larrucea
  • 1,042
  • 10
  • 25
  • It is definitely not physical. Yes, I have updated grub. – ig343 Mar 26 '17 at 16:50
  • Have you tried booting from a live CD? I happen to have a similar problem right now and I am comparing settings between a good and a bad machine. If a live CD session works properly, you could try to compare the outputs of, for example: `env`, `locale`, `localectl` or `locale charmap`. – Julen Larrucea Mar 27 '17 at 16:51
  • The thing is my computer works normally most of times. This just happens from time to time, so it is hard to compare. – ig343 Mar 28 '17 at 05:31
  • It sounds like a tricky problem. Maybe you could make a script that outputs all the related information and save it into a file (including all commands above). Then run it again when the problem reappears and make a `diff` or something with both files. – Julen Larrucea Mar 28 '17 at 07:53