Mohamed Elashri

The Mystery of the Missing Backtick

I hit a frustrating issue today that had me questioning my entire keyboard setup. Every time I tried to type a backtick for Markdown code blocks, I got § instead. Not great when you're trying to document code.

My first thought was the obvious one: wrong keyboard layout. I'm currently using a generic external keyboard on my Mac, and these things can default to European layouts where that key legitimately produces §. So I did what anyone would do, went straight to System Settings → Keyboard → Input Sources and confirmed I was using the ABC (U.S.) layout.

Still got §.

I even checked the keyboard viewer on macOS, and sure enough, it showed § for that key even though "ABC" was selected. At this point, I was convinced it was a hardware issue with my generic keyboard having an ISO physical layout that macOS was somehow detecting incorrectly.

Then I tested my MacBook's built-in keyboard.

Same problem.

Both keyboards producing § instead of `. That ruled out hardware entirely, something system-wide was interfering. I tried the usual suspects:

  • Verified the input source was actually active
  • Removed and re-added keyboard layouts
  • Checked for conflicting input methods
  • Even considered running the keyboard identification wizard

Nothing worked.

The breakthrough came when I checked Karabiner-EventViewer to see what key code was being sent. Interestingly, the keyboard was sending grave_accent_and_tilde correctly, exactly what it should send. But somewhere between Karabiner receiving that signal, and it's reaching my applications, § was appearing instead.

The smoking gun? When I quit Karabiner-Elements entirely, the backtick worked perfectly.

I was using Karabiner to swap left Command and left Option (a pretty standard modification for anyone coming from Linux or Windows). But somehow, this simple swap was causing the backtick issue.

The solution was hiding in a setting I'd never touched before: Karabiner-Elements → Virtual Keyboard settings → Keyboard type.

Mine was set to ISO (or whatever the default was). Changing it to ANSI immediately fixed the problem.

That's it. One dropdown change.

But why? Karabiner-Elements creates a virtual keyboard to process your modifications. If that virtual keyboard is configured as ISO (European layout), it interprets certain key codes differently than ANSI (US layout), even if macOS itself is set to use a US layout. The grave_accent_and_tilde key exists in different physical positions on ISO vs ANSI keyboards, and Karabiner was translating it according to its virtual keyboard type, not the actual physical keyboard or macOS layout setting.

Now I can finally get back to writing proper Markdown without resorting to copy-pasting backticks from other files.