When we want to explain in our documentation which keys a user must press to get to a function we can use the keyboard macro in Asciidoctor. The macro will output the key nicely formatted as a real key on the keyboard. The syntax of the macro is kbd:[key]
. To get the desired output we must set the document attribute experimental
otherwise the macro is not used.
In the next Asciidoctor example file we use the keyboard macro:
= Keyboard macro With the keyboard macro `kbd:[shortcut]` we can include nicely formatted keyboard shortcuts. // We must enable experimental attribute. :experimental: // Define unicode for Apple Command key. :commandkey: ⌘ Press kbd:[{commandkey} + 1] or kbd:[Ctrl + 1] to access the _Project_ view. To zoom out press kbd:[Ctrl + -]. Find files with kbd:[Ctrl + Alt + N] or kbd:[{commandkey} + Shift + N].
When we transform this to HTML with the built-in HTML5 templates we get the following output:
Written with Asciidoctor 1.5.2.