A simple way to style keyboard shortcuts in your documentation.
This package was inspired by auth0/kbd and dogezen/badgery. Also thanks to tweh/menukeys -- A LaTeX package for menu keys generation.
Document generating using typst-community/tidy.
Send them respect and love.
keyle works out of the box — import kbd and go. Keys can be passed as
separate arguments or as one shortcut string; common aliases map to glyphs,
and layout: "mac" switches every key name to its Apple symbol:
#import "@preview/keyle:0.4.0": kbd
#kbd("Ctrl", "Shift", "P") #kbd("Ctrl+Alt+T")
#kbd("cmd", "shift", "P") #kbd("up") #kbd("down")
#let mac = keyle.config(layout: "mac", delim: none)
#mac("Ctrl+Alt+Del") #mac("cmd+Q")Pick one of the nine built-in themes by name (or function) in config:
#let kbd = keyle.config(theme: "flowbite")
#kbd("Ctrl", "K")Every theme is an ordinary function — extend any preset with .with(...):
#let rose = keyle.themes.flowbite.with(
fill: rgb("#fee2e2"),
stroke: rgb("#fca5a5"),
text-args: (fill: rgb("#991b1b"), weight: "bold"),
)
#let kbd = keyle.config(theme: rose)
#kbd("Ctrl", "S") #kbd("Ctrl", "Shift", "S")Non-textual keys are just another kind of symbol:
#let kbd = keyle.config(theme: "flowbite")
#kbd(keyle.svg-key.up) #kbd(keyle.svg-key.down)
#kbd(keyle.svg-key.left) #kbd(keyle.svg-key.right)
#kbd(keyle.svg-key.enter) #kbd(keyle.svg-key.backspace)
#kbd(keyle.svg-key.tab) #kbd(keyle.svg-key.win)Under Typst's HTML export (typst compile --features html), keys are embedded
as inline SVG automatically, or emitted as semantic <kbd> elements with
keyle.config(html: "kbd"). PDF/PNG output is unaffected.
See keyle.pdf for the full manual. Requires Typst 0.15+.
MIT