Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
+1 Nice idea. could look nice. –  Johan Nov 11 '10 at 19:41

5 Answers 5

up vote 47 down vote accepted

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}
\usetikzlibrary{shadows}

\newcommand*\keystroke[1]{%
  \tikz[baseline=(key.base)]
    \node[%
      draw,
      fill=white,
      drop shadow={shadow xshift=0.25ex,shadow yshift=-0.25ex,fill=black,opacity=0.75},
      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}

enter image description here

share|improve this answer
    
Exactly what I needed - Thank you very much! –  Udo Schneider Nov 11 '10 at 20:48
2  
Excellent! So no one will really have to buy a font :) You saved us $120! –  Sadeq Dousti Feb 16 '11 at 23:22
1  
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}
\usepackage{menukeys}

\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

enter image description here

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

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

share|improve this answer
1  
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

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}

enter image description here

share|improve this answer
    
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
1  
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

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

Linux Biolinum Keyboard Sample

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.