I am using TeXstudio 2.12.6 (hg 6632:7777b2b8a906) with Qt-version 5.9.1, compiling with Qt 5.9.1 R.
Although I am a different user, I basically want to resubmit the bug with ticket-no. #2184, since I have the same problem of random ascii smbols inserted in the code, after entering "\" to introduce a command.
Thank you very much for your help!
I experienced the same problem with different versions of TeXstudio over the last years. I never experienced the same error with other programs, but his may be only due to the fact that I barely use the backslash outside of the tex-world.
I use Windows 7x64 with a Cherry keyboard and the out-of-the-box Microsoft driver, without any (known) keyboard utilities installed on the system.
I experience quite frequently the same problem, but not limited to TS but in other programs as well (yet most frequently in TS, across all versions used so far). Therefore, it seems not specific to TS. I use an external keyboard (IBM M, the "machine gun") via a USB-hub (also no extra drivers). I suspect the USB-connection to issue/insert extra-"impulses" being transformed into codes for spades, diamonds, bullets, or other special characters. No idea, what the true reason is, but I don't think, TS is the culprit.
Last edit: Rudi82 2018-11-30
I know what the issue is: this is a bug in TeXMaker and TeXStudio for Windows involving the alt gr key. Unicode characters appear seamingly randomly after releasing the alt gr key, and thus after “\” but also “{”, ”[” or “@” for instance.
I have finally found a consistent way to reproduce the bug! First, some general explanation: I believe the bug happens for every international keyboard layouts with alt gr (french, german, spanish, and many others) but triggers seamingly so rarely and randomly that nobody bothered to fix it. It happens in both TeXMaker and TeXStudio, and I think only in Windows. Indeed, I am pretty sure the root of the problem comes from the fact that alt gr is treated as alt+ctrl in windows.
There's also an unwanted behaviour which might (or might not…) be related: alt gr (or ctrl+alt even in english keyboard layout) + “normal” letter (a, b, … , z) outputs a capital letter A, B, … , Z instead of the lowercase one.
So now, to repoduce the bug:
Initial state: TeXMaker (or TeXStudio) is not opened. Keyboard layout has alt gr.
Steps:
1) Open TeXMaker (or TeXStudio), open a file (new or already created, doesn't matter).
2) Press and release alt gr once.
3) Type a number with distinct digits, using Numpad.
4) Press and release alt gr.
Result: a unicode character appears, as if you had held the alt key, typed the number and released the alt key. For example, typing 1 then tap alt gr outputs ☺ (the alt+1 character), typing 78 then tap alt gr outputs N (the alt+78 character).
As long as you haven't typed all the digits (from 0 to 9), you can input missing ones and you will get a new character after releasing alt gr.
For instance, assuming I am only inputing digits, followed by pressing and releasing the alt gr key, and repeat until I've depleted all the digits, I can get the sequence:
1☺781N1186877♠33♥450┬0123456789↔
And now I should be fine for the rest of my TeX session until I close and reopen the software… or am I? There is another way to “reset” the digits for the bug, so that we don't need to do step 1) again i.e. close and reopen TeXMaker (or TeXStudio) to get the bug for already inputted digits: simply do step 1') Switch the keyboard layout twice (if you switch between two keyboard layouts that have alt gr, you could do it only once, although it seems that sometimes it doesn't resets the digits the first time).
Various remarks:
EDIT: I forgot to mention that, on my french azerty (and bépo) layouts, the bug only happens for Numpad digits. Using the top row digits doesn't count toward the bug.
Last edit: Maxime Oger 2019-02-03
Here: http://www.xm1math.net/texmaker/log_fr.html#contact ?
Thank you, I have sent them a message.
if texmaker and texstudio is affected, it is a general qt problem, nothing directly related to any of this two programs
Please, let's not get into “Qt is the only and single culprit, so won’t fix anything” (in that case, just rewrite TeXStudio without it, since it's clearly not the first Qt-related bug), and actually try to fix the bug or find a way around it that solves the problem.
I have already given a dirty hack that would prevent the bug from happening (even though it is still there under the hood) if implemented directly in TeXMaker/TeXStudio's code: input 0123456789, backspace×10, AltGr at program launch and at every keyboard layout switch.
But as I said, it's the Alt and Ctrl modifiers code which probably need to be fixed. Maybe the warning from Qt's doc “On Windows, when the KeyDown event for this key is sent, the Ctrl+Alt modifiers are also set.” hasn't been taken thoroughly into account. In any case, there is a specific and serious problem to TeXMaker and TeXStudio's code, which needs to get resolved and not swept under the rug.