Skip to content

Instantly share code, notes, and snippets.

@keckelt
Last active February 2, 2025 04:08
Show Gist options
  • Save keckelt/0ba90f8840e2903bfdc54c7e19ad4613 to your computer and use it in GitHub Desktop.
Save keckelt/0ba90f8840e2903bfdc54c7e19ad4613 to your computer and use it in GitHub Desktop.
Avoid typing backticks twice (on Linux and Windows)

Avoid typing backticks twice (on Linux and Windows) using the instructions below :)

The backtick is called grave If the backtick is not typed on your first keyboard button press, but on the second it is a dead grave.

So, find the backtick button keycode for your layout:

xmodmap -pke | grep "grave"

which returns (for my german keyboard layout):

keycode  21 = dead_acute dead_grave dead_acute dead_grave
keycode  49 = dead_circumflex degree asciicircum degree U2032 U2033 notsign notsign grave asciitilde
keycode  51 = numbersign apostrophe numbersign apostrophe rightsinglequotemark dead_breve rightsinglequotemark grave backslash bar

The first entry (keycode 21) is the correct one (the one I physically use), with the acute (forwardtick?) and grave (backtick) symbols. Both have a dead_ prefix, meaning they wait for another keypress.

So all you have to do, is to change the symbols for this keycode. I will keep the dead behaviour for acute (to write Café), but not for grave, so:

xmodmap -e 'keycode 21 = dead_acute grave'

Note that your keycode may be different (e.g., 49 on uk/us keyboards). If you want to have consistent behaviour, remove the dead prefix from acute aswell.

This AHK script inserts backticks directly and provides the dead key behaviour via CTRL+Backtick:

#SingleInstance force
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


; Diable Backtick's dead key behaviour
;escape backtick with dollar sign ($`), send ecape backtick with backtick (``=`), send space to insert
$`::send ``{space} 

; Provide dead key behaviour via CTRL+backtick
; if ctrl+backtick (^`), use normal dead key behaviour
^`::send ``
@mohclips
Copy link

mohclips commented Apr 5, 2023

thanks for this. 😄

@P2Beauchene
Copy link

Thank you so much !
I didn't know about AutoHotkey, I just discovered a world of possibilities.

@keckelt
Copy link
Author

keckelt commented May 5, 2023

Thank you so much ! I didn't know about AutoHotkey, I just discovered a world of possibilities.

Happy to hear 😄

@shino11
Copy link

shino11 commented Feb 2, 2025

thank you for this code,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment