Skip to main content
10 of 16
deleted 64 characters in body
Brock Adams
  • 13k
  • 5
  • 39
  • 64

<kbd> markup shortcuts

Update in progress...
Version 2 is stable.

Inspired by the question, "Markdown syntax for <kbd>foo</kbd>", this script adds both a button and a keyboard shortcut to each post's <textarea> (when editing posts).

Press the button or press AltK on the keyboard and <kbd></kbd> will be inserted at the cursor.
If text is selected, it will be wrapped by the <kbd> tags instead.

Tested the script on both Firefox (needs the Greasemonkey add-on) and Chrome (might work for Opera too).

Screenshot:
This script in action


To install, click here (Add_kbd_shortcut.user.js install at Github).

To preview the source, click here (Add_kbd_shortcut.user.js preview at Github).


Known limitations, possible future enhancements:

This shortcut handles leading and trailing whitespace the same way that other SE shortcuts (Bold, Italic, Code) do.

This shortcut now wraps and unwraps the same way that other SE shortcuts (Bold, Italic, Code) do.

Brock Adams
  • 13k
  • 5
  • 39
  • 64