k

keyle

@preview

This package provides a simple way to style keyboard shortcuts in your documentation.

v0.4.0
MIT

Package Information

Last Updated
Minimum Typst Version
0.15.0
Authors
wesleyel
Categories
utilityfun

1. Get the package

Download the package using the TPIX CLI:

tpix get @preview/keyle:0.4.0

2. Import in your Typst file

Add this to your .typ file:

#import "@preview/keyle:0.4.0": *

Version History

0.4.00.15.0
24e8e0324d26...
0.3.00.13.0
90e2e09ab5d9...
0.2.00.11.1
505aaed3a8a1...
0.1.10.11.1
d15e707feb29...
0.1.00.11.1
a75f801d2ce5...

keyle

keyle package manual MIT License

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.

Usage

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")

keyle quick start

Themes

Pick one of the nine built-in themes by name (or function) in config:

#let kbd = keyle.config(theme: "flowbite")
#kbd("Ctrl", "K")

keyle built-in themes

Customization

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")

keyle theme customization

SVG key glyphs

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)

keyle svg key glyphs

HTML export

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+.

License

MIT