"Alt Gr" is equal to pressing "Alt" + "Ctrl". Now, if you hold "Alt Gr" for something like a second, it will be as if you released "Alt" but NOT "Ctrl".
Using an AZERTY keyboard, "Alt Gr" is needed for several characters that are useful for commands : " ~ " , "@" , " ^ " , "{ }" and "[ ]"
Because it simulates a locked "Ctrl", actions like deleting text or moving the cursor with arrows will be work "word by word" instead of "character by character". For example :
/give @a[distance=..10,limit=5,sort=random] minecraft:blue_wool
First, if you do a typo, you're likely to not realise about the bug and delete the whole argument, if not several of them (here, write "blue_wiil" and you have what you need to delete literally everything. Although the most annoying is often when deleting a target selector).
Now, if you want to change to "red_wool", and / or something in the target selector maybe, you will have write the whole argument again (but the most annoying is really when you delete everything just because you didn't realise the bug was there. While most people probably won't even understand what the bug is)
Another problem is that Ctrl + A selects the whole text, but the game then still writes the letter too. So because of that, whenever you press the letter "A", everything you wrote will be replaced by "a". It took me quite some time to realize that because of MC-121278.
But what it means is : if MC-121278 is solved before this one is, it will become far, FAR worse than it is now ! (as long as it's not solved, it is the letter "q" that is a real problem, but it is rather uncommon. Which is not at all the case of the letter "a")
Pressing "v" can be annoying too, but at least it won't make you lose everything, it's a less common letter, and if you pressed "c" or "x" before, you won't notice anything. Unless you needed for later use what you last copied, since you won't have anymore anything to paste. Anywhere).
Notes :
1) There is a way to stop this bug : Press the LEFT "Ctrl" key (the right one does nothing. At least for me).
2) While holding "Alt Gr", pressing another key before the bug starts ensures that it will never start (until you release then hold again "Alt Gr").
3) The bug seems to be related to a "bad" framerate (including minor / average fps drops while otherwise having a good framerate), and maybe lag spikes, although the bug never seems to start instantaneously (and a lag spike is pretty short).
Related issues
is duplicated by
relates to
Comments


Just tried with another keyboard, it does the same (that's the same layout though, so I wasn't expecting much). I already tried to switch to QWERTY using Shift + Alt, too, but it doesn't work in Minecraft (even if I do that while on the desktop then go back to Minecraft, my keyboard is back to AZERTY), so I don't think I can test much more by myself.
And yes, it does that only on Minecraft (and never noticed that in 1.12.2 or before, so I assume it wasn't doing that there).

AltGr is equal to pressing Ctrl+Alt, so the control key might stay pressed to the game even though you stopped pressing AltGr

Had in mind that it was equal to Ctrl + Shift (thinking about it, I'm stupid. It's ALT Gr, after all ^^' ), so that was what I tried. Just tried again with Alt instead of Shift then, and both with left and right Ctrl, and it doesn't lock Ctrl (I'm not going to do Ctrl + Alt instead of Alt gr though). No matters if I press Ctrl first or Alt first.
In any case, the control key staying virtually pressed is what I though too (now, why it does that ? Would be great to know if other people with AZERTY layout have this issue as well, and even more if there are people with a QWERTY layout that have it too)
PS : Actually just thought of a test I could do : Removing the AZERTY layout from my computer to leave only the QWERTY one, so that the game cannot change back to AZERTY (tried first to only make QWERTY as main keyboard but it wasn't enough). Even though I'd still like to see if it does that to other people too, the result here is that the bug stil occurs, in QWERTY as well.

Still in 1.13pre1

Rewrote the description. I think it was needed (and I hope it's indeed better now, but I'd say it is).

I have the same issue too and I noticed that quickly spinning your mouse while holding AltGr is a more consistent way (at least for me) to encounter this problem.
My theory is that this problem is caused by having a small lag spike while holding AltGr. I play Minecraft on a pretty bad laptop, thus changing my field of view very rapidly is already enough to cause some lag.
Another sign that lag could be cause of this issue is that in a void world where my game obviously isn't lagging, I can hold the AltGr-key for a minute without Ctrl getting stuck. But when I quickly move my mouse and thus cause a small amount of lag, the Ctrl-key is stuck only after a few seconds of moving the mouse.
Furthermore, intentionally lagging my game with some redstone contraptions made this issue even more easily reproducible.
I can also confirm that this issue never happened in 1.12 and started happening in the first 1.13 snapshot (17w43a).
I use the German keyboard layout.

@ToseRedstone
Weird, but interesting and it could make sense. I'll investigate to see if what you say applies to me as well.
Thank you 🙂

Can someone please check if this is still an issue in -pre4?

Still happens in pre4

@Michael Wobst
Yes, it still is. It just so happens that I was doing my tests on it ^^ And so, it indeed seems to be to to framerate. But I do say to framerate, not lag spikes ! Thing is, I limit my Minecraft's framerate at 30 fps. And even in a void world, without moving and checking my framerate with Alt + F3, I quickly end up with a virtually locked Ctrl. And of course, I made sure it was the case even when not having the slightest lag spike while holding Alt Gr.
Then, since I was in a void world (and that overheating isn't instananeous), I tried turning my framerate to "Unlimited". I've been quite surprised to see that I could reach approximately 250 fps (but hey, void world, not moving at all, and by the time I finished testing, I was more around 150 fps), and it was much more constant than I thought it would be. Also, although I was still able to reproduce the bug, it indeed became harder.
For exemple, one thing I've done, both with 30 fps max and unlimited fps, was to write a bunch of letters, then repeat the two following steps : holding Alt Gr for a short time (say 0.5-0.7s), then pressing backspace. When limited to 30 fps, I would usually get the bug after 3-5 iterations. With unlimited fps it was much harder, and even when trying to hold Alt Gr for a longer time (maybe 3s ?), the bug wouldn't start easily.
Once more thing : It really seems to be caused by more or less low framrate, but it doesn't seem to be the case for lag spikes. Or maybe you would have to release Alt Gr after the lag spike starts but before it stops, in which case it would require quite a great timing, but I'm not sure (I mean, it can't be exclusive to lag spikes since I can reproduce the bug incredibly easily, all the time, while my fps is limited to 30 and I have no lag spike at all).

Confirmed for 1.13 pre5

Confirmed for 1.13 pre6

Confirmed in 1.13pre7

I have a decent PC and am typing commands in a flat world with constant 600 FPS and it still occurs... I think it's safe to assume, framerate or lagspikes have nothing to do with this...
Please devs! This is incredibly annoying to randomly get way to much in your command removed by backspace or even your whole command by just pressing "A" because that triggered a ctrl-A thanks to the sticking key and then overwrite all the selected text with an A. I really can't comprehend how something like this isn't fixed yet...
Edit: Also, as I'm typing commands, I'm not moving my mouse at all either... Happens on both my main PC and my Laptop, while trying to type [] or {} for entity selectors and nbt on a german QWERTZ keyboard.
Everyone who has this problem: What operating system do you use? I'm using Windows 10, and I haven't been able to reproduce this, and I tested it with many different keyboard layouts.

I'm also using Windows 10

Isn't that the n-key-rollover-issue MC-54194 ?

I'm using windows 10 as well, on both main PC and laptop. Just typing commands that often require me to press alt-gr it's like hit or miss every time with about of a 50% chance of it being stuck afterwards...
Wtf, I just made a new world, and I can't seem to reproduce it in that one either anymore... How is it even possible for the world being the cause...
Nvm now it's happening in the new world again...

@Kumasasa
No, it's something different. The issue you linked involves pressing simultaneous keys, but is not in any way caused by Minecraft (as stated there. There are plenty of combinations that are impossible, but precisely because it's a hardware issue, these combinations are 'never' the same from a keyboard to another).
Here, it is by holding for a little too long a single key ("Alt Gr"), and that's an issue that wasn't there in 1.12.2.
@Dominik
Not seeing the fps fluctuate doesn't mean they don't fluctuate. And although I highly doubt the bug is caused by low framerate, it does seem to worsen it (at least in some cases). Doesn't mean it's the case, but you should check with Alt + F3 (the graph don't show up every time, so it may be necessary to try several times, and it never works when F3 infos are already visible, so hide them first), you should check if you have at least some little lag spikes, when playing normally, that would bring you... let's say under 60 fps. You can try as well to limit your fps to 30, to check if it gets worse or not.
@Violine
I'm on Windows 7. But it looks like it's not due to the OS anyway.
Did you try to limit the fps to 30 ? Also, maybe you didn't wait long enough ?

@Kumasasa I'm using Windows 8.1

Still in 1.13

Still in 1.14 and for me it neary always happens when I try to type Selectors(I have QWERTZ Layout) like @a.

I thought I was going insane. Happens to me on 1.14.4 (java on windows 10) constantly. I noticed that this occurs almost everytime when you hold the key longer but it also happens on very short presses. So I assume the game does something regularly with the key states that doesn't handle altgr correctly. So if it's pressed in this moment leftCtrl gets stuck.
This happens a lot of times when I enter []{} which happens quite often when working with commands and if you then try to correct a typo it usually removes the whole selector or NBT which is quite infuriating to say the least.
Additionally I would like to mention that this occurred on a local superflat world with no lag spikes according to graph and constant 20TPS

Can anyone still reproduce this bug ? I assume it's still there, but I'm on a new computer now, and I can't seem to reproduce it anymore (even tried putting something on Alt Gr while I was away, which was for about 1h30min, but no. That was on 1.14.4, which was already confirmed by @Sven).
I've been thinking it could maybe be caused by hardware ? My laptop (on which I had the bug) had Intel i3 CPU and NVidia GPU (GTX 410M I think). My new PC has AMD Ryzen 5 1600 CPU and AMD RX570 GPU.
And Windows 10, although it doesn't seem at all to change anything.
EDIT : Also my framerate was still limited to 30 (like before). Since I talked about framerate that may be at least part of the issue. Although I probably had a quite more stable 30 fps than on my laptop.

I can't seem to reproduce it in the latest snapshot either. Before that I could barely do anything because it kept happening pretty much everytime I tried to type an entity selector (which, on a QWERTZ keyboard requires altgr and Q, 8, 9). Everytime it would cause altgr to get stuck, and when I tried to move my cursor back into the selector, to specify parameters, it would go to the beginning of it.
But yeah, seems to have fixed itself, if nobody else proves me wrong. I did not really have any hardware upgrades like you did @Azkunki, so I would assume, that that is not what fixed it for you.
Also just went back to 1.14.4 and checked, took a while to reproduce it, but it did get stuck again in the end.

That's good news I guess ! Although it would be nice to get feedback from more people. In any case, I may check on my laptop later (since I still have it), it would be interesting to see if I can still reproduce that bug. Especially that I think on the contrary the new hardware helped for me ^^ (although not necessarily from being more powerful) I mean, pressing Alt Gr for about 1h30min was on 1.14.4, where we know the bug wasn't fixed ! (doesnt mean it was fixed for me, but it became at least really hard to reproduce, thus either impossible or very unlikely to happen under normal circumstances).
I never tried myself on that version though (not on my laptop), only on 1.14 (and without Optifine, since it wasn't out yet back then (may be a nice idea for my test on my laptop to do it without Optifine actually, and if I can reproduce the bug, try again but this time with Optifine). Even with 1.13 I never tried reproducing it with Optifine, I was barely launching the game once in a while for some tests).

Yeah, still happens on my laptop (maybe a little harder, but still pretty easily).

Still a problem in my testing

So annoying glitch. This issue has been a thing for i think, since the commands have been rewrite to be easier i do not remember in which version though.
Still present in latest 20w07

Reproduced in 20w16a. When I type commands with ~ which uses AltGr, I run into the bug about once a minute and end up deleting half the command when I press backspace, it's so annoying.. didn't happen in 1.12 or before.

I have got the same issue. I am left handed so i use plöä instead of wasd, right-shift to sneak, space to jump and AltGr to sprint. I've got a new Computer (also new keyboard) and it is still a problem. The most annoing thing is that with Ctrl + F3 + L you can "Reaload visible Chunks" (Can someone tell me what this is good for?). This couses Minecraft to crash almoast every time, and I often accidently hit it if I want to press F3 + B to show the hitboxes. Than I want to move, hit L because of my Controls, and the game crashes.
This is still a Problem in 1.15.2 with and without OptiFine.

For everyone who got this issue, I recommend this AutoHotKey program: https://pastebin.com/sxu0Uaaf
I've been using it for a while now and it really help a lot. It doesn't work perfectly well, sometimes the chat still clears when pressing a, but that's probably only 1% of the time. This small script made Minecraft playable for me again.

This is a really annoying issue, why hasn't it been resolved yet? It's still present in the first 1.17 snapshot

Still same issue and when it started, it will appears every single Minecraft version. Even with the mods. 1.17 - 20w51a snapshot.

I work with commandblocks all the time and I only recently ran into this error. It started on minecraft fabric 1.16.4 and then even in vanilla minecraft versions 1.16.4, 1.16.5 and the snapshot versions of 1.17. I don't seem to be able to recreate this bug, it just randomly appears but is most likely to appear when using the execute commands with all its variables such as "~, @, [], {}. It always delets the complete command section when the letter "a" is typed :/

I can confirm the issue still occurs on 1.18.1. It is very iritating and makes typing in chat in a language that requires using the Alt Gr key often very difficult. I can provide some more information on the subject:
I can confirm pressing left control or clicking outside the Minecraft window usually fixes the problem.
In my experience, the bug can be much more difficult to reproduce while debugging.
I have a very fast computer with a consistantly high framerate, so low FPS isn't nessecarily a factor.
It seems the issue doesn't nessecarily happen to everyone, however, it's definitely required to use a keyboard layout that uses the Alt Gr key (In my case I'm using the Polish (programmer) keyboard layout).
The two easiest ways I found to trigger the bug are the following:
(The recodring software I use sees pressing Alt Gr as pressing right alt and left control at the same time)
1. In the chat text box, simultaneously spam the letter 'a' and Alt Gr on your keyboard as hard as you can. This will result in the text box occassionally entering a state where the box behaves as if control was continually pressed (meaning backspace deletes whole words, the letter 'a' deletes the entire text and adds an 'a' at the end, and the arrow keys move the cursor in the same way as if control is pressed) (demonstration: https://youtu.be/ujnOdIAE8vY)
2. Walk (don't sprint) and spam the Alt Gr key. This will cause the player to start sprinting (demonstration: https://youtu.be/IOJipEcblkc)The issue (at least in the case of text fields, not necessarily for example 2. that I gave previously) seems to come from the fact that while the bug is active, GLFW.glfwGetKey for GLFW.GLFW_KEY_LEFT_CONTROL returns 1, even when no alt or control keys are pressed on the keyboard (At this time, GLFW.glfwGetKey for GLFW.GLFW_KEY_RIGHT_ALT and GLFW.GLFW_MOD_ALT both return 0).
I have created a temporary and hacky fix for the bug in the form of a fabric mod for anyone else that is iritated by this: https://github.com/MikolajKolek/fix-alt-gr

Issue also occurs in 1.19.2-rc2

Can confirm in 23w03a

Hello, I found this issue also on 1.19.3. After clicking [Shift + Alt] it disappeared.

That's still present in 23w14a.
I think is in part a hardware issue, but as many of you state, it only happens on Minecraft...
Windows 11 with Razer Blackwidow v3 mini (Wireless) with Spanish layout.
Since there are already many ways to replicate that issue, i'm commenting to post some help for people that needs a tempotary workaround while that bug is still present because that makes the game super anoying for those who like me works with commands a lot of the time.
If you are a Windows user, you can use the "Microsoft PowerToys" and use the integrated Keybaord Manager to translate "Alt (Right)" into "Ctrl (Left) + Alt (Left) + Undefined". It may look like it will do nothing, but for me it prevents the bad behaviour in Minecraft while the keyboard still works as normal in any environment.

Still present in 1.19.4. It completely ruins commands for many people. For example, the german keyboard layout requires you to press AltGr for {[]}, 4 very important characters. Its a shame that this hasn't been fixed after 5 years.

Still happens in 1.20.1 with QWERTZ (German) keyboard layout on different computers, doesn't matter if Win10 or 11.

This still happens in 1.20.4
I am using Windows 10
For me, it wasn't a problem until I got my new laptop, on the old one, it never happened
(We would appreciate a fix, it's really annoying to write commands)

Can confirm for 1.20.4
Bery annoying bug especially for users needing to press this key to be able to enter ~{}[]\
I could always reset it by alt tabbing but that is more than annying. Because sometimes it fully resets progress for writing long commands and chat messages

Can confirm for 1.20.6

The Problem with "ALTGR" still exists for Version 1.21 Tricky Trials Update.
I'm using QWERT key board with Swedish layout.

Can confirm for 1.21 as well as 24w33a with German QWERTZ

Confirmed for 1.21 on Windows 11 QWERTY Spanish Layout
This bug has been bothering me for a long time

Confirmed for 1.21 on Windows 11 Azerty French Layout
The bug is still there and it is very annoying when trying to create commands and command blocks.

This also happens in 1.20.1 with QWERTY tr keyboard layout

Can confirm in 24w39a

On Qwerty too in 1.21.1
Have you tried with other keyboards? Does it happens everywhere or just Minecraft? Might be an accesibility setting