Making a backtick produce just a backtick
My backtick key (`) produces nothing when first pressed - I have to press it twice to generate a `. If I forget, and type ` e, I get an accented e character.
I am only able to fix this temporarily, for the current session, by running:
xmodmap -e 'keycode 49 = grave asciitilde'
The problem is, I can't figure out how to make this change permanent. I have found many related questions on Ask Ubuntu, but none that solve this specific problem.
I am using KDE.
Solution 1:
In system preferences, keyboard layouts, there's three UK "variants":
Layout Variants
------ --------
English (UK) Default
English (UK) English (UK, extended WinKeys)
English (UK) English (UK, international with dead keys)
My keyboard has windows keys, so I'd selected the second variant during the install process, as seemed reasonable.
In fact, the difference between "Default" and the "extended WinKeys" variant seems to have nothing to do with the Windows keys at all. The "extended WinKeys" variant actually makes many changes to the AltGr key behaviour, most of them for the better, for example, the AltGr-shifted apostrophe and circumflex keys add the acute and circumflex accent to the next letter that's pressed, rather than the random results that the "Default" variant gives.
However, the "extended Winkeys" variant also corrects the AltGr-shifted backtick, and returns a broken-bar as is printed on the key rather the incorrect solid-bar provided by "Default". That in turn means that the AltGr-backtick can't be used to add the grave accent to the next letter, as would be consistent with the "extended Winkeys" variant, so somebody evidently decided to just replace the backtick with that function.
Since any UK Linux user would use the Compose-key functionality to write accented letters, nobody knows about the differences between these keyboard variants and it just catches people out. In the various forums that mention the backtick-key giving this unexpected behaviour, everybody was mystified about why it happened.
This is the sort of thing that this bug causes. If I wanted to display the content of a shell script that somewhere on the path, I might type:
$ cat `which zegrep`
But instead, I get:
$ cat ẁhich zegrep
...the backtick and "w" combine into w-with-grave
This is the mapping of the backtick key with the UK "extended WinKeys" layout:
$ xmodmap -pke | grep "keycode 49"
keycode 49 = dead_grave notsign grave notsign brokenbar notsign bar bar
And if you change the keyboard layout to UK "Default", the dead_grave key mapping gets shifted to the third position, which is the "mode_shifted" position (enabled by a Mode_shift key if you had one defined on your keyboard) which makes much more sense:
$ xmodmap -pke | grep "keycode 49"
keycode 49 = grave notsign dead_grave notsign bar bar brokenbar notsign
I'm thinking that I should report a bug, since evidently other people run into this, but I'm not sure what to recommend. Maybe rename "UK, extended WinKeys" to "UK, deadkeys via AltGr", so that people generally wouldn't select it unless they knew what "deadkeys" were and specifically wanted that behaviour. Or shift the dead_grave function to the AltGr-shifted position on the backtick key, which would make it consistent with the other deadkeys.
Anyway, just goto the keyboard layouts, add a new layout and select the UK Default keyboard.
Solution 2:
This is called a "dead key". Look for a variant of your keyboard layout that says something like "eliminate dead keys" or a variant which is not "dead keys". For the gb keyboard, the variant is called English (UK)
I think. You can also set it with command line:
setxkbmap -layout gb -variant basic
However, this will not be permanent. Fint the basic
If you do not find one like that, it is possible (and quite easy) to create your own layout.