Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This is a userscript that adds shortcuts for adding <kbd> tags to posts. Designed for Stack Exchange sites.
// ==UserScript==
// @name OBSOLETE: StackExchange, Add kbd shortcut
// @description Adds a button and a keyboard shortcut (Alt-K) to add <kbd> tags.
// @version 1.3
// @match *://**
// @match *://**
// @match *://**
// @match *://**
// @match *://**
// @match *://**
// @match *://**
// ==/UserScript==
//-- On SE pages, use SE's error popup:
var targNode = $("#hmenus, .so-header").first ();
var seUtils = window.StackExchange;
console.warn ( `
This version of the "StackExchange, Add kbd shortcut" script is broken and obsolete.
Please uninstall it and (optionally) install the fixed and upgraded script.
The new script has been moved to GitHub proper. Find it at:
For more information, see the post at Stack Apps:
` );
var alertMsg = `This version of the "Add kbd shortcut" script is obsolete. See the console for more info.`;
if (targNode.length && objHas (seUtils, "helpers.showErrorPopup") ) {
seUtils.helpers.showErrorPopup (targNode, alertMsg);
alert (alertMsg);
function objHas (obj, key) {
//-- Needed because .hasOwnProperty() does not work for nested properties. :(
return key.split (".").every (_rcrsvlyChkPropname);
//-- Declared function for better performance...
function _rcrsvlyChkPropname (propName) {
if ( obj === null || typeof obj !== "object" || ! (propName in obj) ) {
return false;
obj = obj[propName];
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.