# Keyboard Font for LaTeX

I'm currently writing a user guide containing a lot of keyboard shortcuts. I'm looking for a "keyboard" font where single characters or special keys (like tab or backspace) appear like the "real" key (i.e. with a box around; hope you get the idea).

Is there any package available for this or do I have to wrap one of the existing PS/TTF Fonts?

-
+1 Nice idea. could look nice. –  Johan Nov 11 '10 at 19:41

The keystroke package is your friend.

Update:

Sadeq's suggestion could be mimicked very inexpensively by the pgf/tikZ package.

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\newcommand*\keystroke[1]{%
\tikz[baseline=(key.base)]
\node[%
draw,
fill=white,
rectangle,
rounded corners=2pt,
inner sep=1pt,
line width=0.5pt,
font=\scriptsize\sffamily
](key) {#1\strut}
;
}

\begin{document}
The quick brown fox jumps over the lazy dog. \keystroke{Strg} The quick brown fox jumps over the lazy dog. \keystroke{Ctrl} The quick brown fox jumps over the lazy dog. \keystroke{Page $\uparrow$} \keystroke{Esc} \keystroke{F1}
\end{document}

-
Exactly what I needed - Thank you very much! –  Udo Schneider Nov 11 '10 at 20:48
Excellent! So no one will really have to buy a font :) You saved us \$120! –  Sadeq Dousti Feb 16 '11 at 23:22
It was a great starting point. Now I am using following code (works correctly w/ sequences like Ctrl+F1): \renewcommand*\keystroke[1]{\hspace{0.2ex}\tikz[baseline=(key.base)]\node[draw,‌​text height=1.5ex,text depth=0ex,fill=black!10,drop shadow={shadow xshift=0.2ex,shadow yshift=-0.2ex,fill=black,opacity=0.50},rectangle,rounded corners=2pt,inner sep=2.75pt,line width=0.5pt,font=\footnotesize\sffamily] (key) {#1};\hspace{0.4ex}}. \re..., because I still use keystroke package for convenient \PgUp and similar macros (you have to add \ after them if used in the middle of sentence, etc.). –  przemoc Jul 7 '11 at 14:37

You can use the menukeys package.

## Example

\documentclass[a5paper,9pt]{scrartcl}
\usepackage[utf8]{inputenc}

\begin{document}
\section{The Manual}
You can visualize paths \directory{/home/moose/Desktop/manual.tex}
or menus \menu{View > Highlight Mode > Markup > LaTeX} or key
press combinations: \keys{\ctrl + \shift + F} is for formatting
in Eclipse.

You can also visualize \keys{\tab}, \keys{\capslock}, \keys{\Space},
\keys{\arrowkeyup} and many more.
\end{document}

## Rendered

-
Is the package \menukeys in a standard latex installation or do we have to download it via CTAN? –  71GA Sep 26 '13 at 6:52

Another free keyboard font is Linux Biolinum Keyboard. See the following graphic for an example:

-
Yes, and linux libertine. They're nicer than keystroke. –  Leo Liu Feb 16 '11 at 14:18
Very nice. But only available with the Libertine font. –  Thorsten Donig Feb 16 '11 at 19:41

the ones with Libertine:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{libertinekey}

\begin{document}

\LKeyStrg\ The quick brown fox jumps over the lazy dog. \\
\LKeyStrg\ The quick brown fox jumps over the lazy dog. \\
\LKeyPos\ \LKeyEsc \LKeyF{1}

\end{document}

-
This package seems to have been depreciated. Will you please update the answer with the latest version (I think is libertineOTF). –  Yiannis Lazarides Mar 15 '12 at 22:32
why should it be deprecated? The above is an example for pdflatex and not xetex or luatex! –  Herbert Mar 15 '12 at 22:57
Look into libertinekey.sty (in an up-to-date distribution). It is unfortunately needed to load libertine.sty from libertine-legacy. –  Speravir Mar 16 '12 at 2:29
I see, but that seems to be a bug. All packages of libertine-legacy should be the old one. I'll report it. –  Herbert Mar 16 '12 at 5:43