Skip to content

Keyboard Keys#

View Markdown

Product docs and editor guides often need shortcuts such as Ctrl K or Command Shift P. {kbd:...} markup is opt-in and off by default.

Option Type Default
keyboardKeys boolean / KeyboardKeysOptions false
import { oxContent } from "@ox-content/vite-plugin";

export default {
  plugins: [
    oxContent({
      keyboardKeys: true,
    }),
  ],
};

false or omitted leaves the source unchanged. true or an object enables the transform. There is no client JavaScript and no runtime platform sniffing.

Authoring#

Write {kbd:Ctrl+K} or {kbd:Cmd Shift P}. + and whitespace both split keys. The renderer emits nested <kbd> elements with stable classes:

CtrlK CommandShiftP Esc

Press {kbd:Ctrl+K} or {kbd:Cmd Shift P}.

Press CtrlK or CommandShiftP.

Single keys, punctuation, and combinations are all valid. Built-in aliases such as cmd, ctrl, shift, and esc normalize only when the feature is on. Unknown tokens stay as written.

`{kbd:Ctrl+K}`

{kbd:Ctrl+K}

Escape a literal with a backslash: \{kbd:Ctrl+K} stays {kbd:Ctrl+K}. Empty, unclosed, or newline-spanning markup stays visible. Fenced, indented, and inline code, HTML comments, and raw code / pre / script / style are not rewritten.

Options#

oxContent({
  keyboardKeys: {
    style: "symbols",
    aliases: {
      cmd: "Cmd",
    },
  },
});
Field Type Default
enabled boolean true
style "words" / "symbols" "words"
aliases Record<string, string> {}

style: "words" turns cmd into Command. style: "symbols" turns it into . Custom aliases are matched case-insensitively and override the built-in table. Labels are chosen at build time.

Last updated: