0 users online. Create an account or sign in to join them.Users

Author:
wjnielsen
Version:
1.0.0
Release Date:
24 Aug 2012
Category:
Date & Time

Description

Simple XSL template for calling up keyboard key symbols.

I've used it for instructing users to hold down the CTRL or ? keys when selecting multiple items from a multiple select list.

GitHub Repo

XSLT

View Raw
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template name="symbols">
        <xsl:param name="name"/>
        <xsl:variable name="output">
            <xsl:choose>
                <xsl:when test="$name = 'apple-alt'">&#x2325;</xsl:when>
                <xsl:when test="$name = 'apple-command'">&#x2318;</xsl:when>
                <!-- apple-logo not guaranteed to work on non-apple systems -->
                <xsl:when test="$name = 'apple-logo'">&#xF8FF;</xsl:when>
                <xsl:when test="$name = 'apple-option'">&#x2325;</xsl:when>
                <xsl:when test="$name = 'alt'">ALT</xsl:when>
                <xsl:when test="$name = 'alt-key'">ALT</xsl:when>
                <xsl:when test="$name = 'control'">CTRL</xsl:when>
                <xsl:when test="$name = 'control-key'">CTRL</xsl:when>
                <xsl:when test="$name = 'delete'">&#x232B;</xsl:when>
                <xsl:when test="$name = 'delete-key'">&#x232B;</xsl:when>
                <xsl:when test="$name = 'escape'">&#x238B;</xsl:when>
                <xsl:when test="$name = 'escape-key'">&#x238B;</xsl:when>
                <xsl:when test="$name = 'power'">&#x233D;</xsl:when>
                <xsl:when test="$name = 'power-button'">&#x233D;</xsl:when>
                <xsl:when test="$name = 'return'">&#x23CE;</xsl:when>
                <xsl:when test="$name = 'return-key'">&#x23CE;</xsl:when>
                <xsl:when test="$name = 'shift'">&#x21E7;</xsl:when>
                <xsl:when test="$name = 'shift-key'">&#x21E7;</xsl:when>
                <xsl:when test="$name = 'tab'">&#x21E5;</xsl:when>
                <xsl:when test="$name = 'tab-key'">&#x21E5;</xsl:when>
            </xsl:choose>
        </xsl:variable>

        <xsl:if test="$output != ''">
            <kbd>
                <xsl:value-of select="$output"/>
            </kbd>
        </xsl:if>
    </xsl:template>

</xsl:stylesheet>

Discuss this XSLT Utility

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.1
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details