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
What is a "standard latex installation"? It is included in texlive-full if that is the question. –  moose Sep 1 '14 at 10:08
This was the question yes. –  71GA Sep 2 '14 at 11:03

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

Thorsten Donig's answer is excellent, and provides a free solution. However, if you are in need of a more advanced typographic solution, you may consider buying fonts specially designed to represent "keyboard caps."

One such font is the family of PIXymbols Shadowkey fonts. In my opinion, they are prettier (but much more expensive!)

-
Or use an open-source such font, like Linux Biolinum. –  ℝaphink Sep 14 '11 at 13:27
@Raphink: See Philipp's answer! –  Sadeq Dousti Sep 14 '11 at 21:38

As a supplement to Philipp's answer, I'm providing a MWE for the Linux Biolinum Keyboard font. You need to compile with xelatex or lualatex. The macros are given in the libertine documentation.

\documentclass{article}
\usepackage{libertine}
\begin{document}

First hit this key sequence:\LKeyShiftX{H}

Then hit these keys one by one:
\LKey{E}\LKey{L}\LKey{L}\LKey{O}\LKeySpace\LKey{W}\LKey{O}\LKey{R}\LKey{L}\LKey{D}

And finally hit the \LKeyEnter\ key.

You should now see the phrase Hello world'' on your screen.

\end{document}


-

Arkandis also provides 2 keyboard fonts, suitable for, I think, French keyboards. These can be used directly with Xe/LuaTeX.

Code is a hacked version of egreg's answer:

\documentclass[a4paper,12pt]{article}% ref. egreg's answer at http://tex.stackexchange.com/a/23866/
\usepackage[landscape,textwidth=239mm,textheight=480pt]{geometry}
\usepackage{fontspec,setspace}
\newcount\charcount
\parindent=0pt
\doublespacing
\begin{document}

\keyone
\chardef\highest=\XeTeXcountglyphs\font
\offinterlineskip
\loop
\makebox[35mm][l]{\strut\vrule\,{\normalfont\number\charcount}\hfill \XeTeXglyph\charcount}\hskip1mm plus 1mm
\ifnum\charcount<\numexpr\highest-1\relax
\repeat
\newpage

\keytwo
\charcount=0
\chardef\highest=\XeTeXcountglyphs\font
\offinterlineskip
\loop
\makebox[35mm][l]{\strut\vrule\,{\normalfont\number\charcount}\hfill \XeTeXglyph\charcount}\hskip1mm plus 1mm
\ifnum\charcount<\numexpr\highest-1\relax