Use multimedia keys

Users can use their multimedia keys to cause events or enter special characters. Here I put the characters ☹, ☺, and ☻ on the first 3 keys, when shift is pressed at the same time. Users of Microsoftʼs Windows® may be able to use their Keyboard Layout Creator

It can be set in ~/.Xsession or for gnome users add it to the list of startup programs. Use shift to access your character choices, as your desktop may override the unshifted keys to set off the labelled action.

#!/bin/bash
# 236, 178, 230, 162, 164, 166, 160, 237, 235, 161
# cause an event from /usr/share/X11/XKeysymDB
# or enter UTF-16 NNNN char by writing 0x0100NNNN
# find key scan codes with xev
xmodmap -e 'keycode 236 = XF86Mail 0x01002615'
xmodmap -e 'keycode 178 = XF86HomePage 0x0100263B'
xmodmap -e 'keycode 230 = XF86Favorites 0x01002408'
xmodmap -e 'keycode 162 = XF86AudioPause 0x01002026'
xmodmap -e 'keycode 174 = XF86AudioLowerVolume 0x01002639'
xmodmap -e 'keycode 176 = XF86AudioRaiseVolume 0x0100263A'
xmodmap -e 'keycode 160 = XF86AudioMute 0x01002018'
xmodmap -e 'keycode 237 = XF86AudioRecord 0x01002019'
xmodmap -e 'keycode 235 = XF86MyComputer 0x0100201C'
xmodmap -e 'keycode 161 = XF86Calculator 0x0100201D

If you don’t have multimedia keys, can use AltGr keys for favourite characters:

#xmodmap -e 'keycode  10 = 1 exclam 1 exclam 0x01002620 0x0100263A'
#xmodmap -e 'keycode  11 = 2 quotedbl 2 quotedbl 0x01002620 0x0100263A'
#xmodmap -e 'keycode  12 = 3 sterling 3 sterling 0x01002620 0x0100263A'
#xmodmap -e 'keycode  13 = 4 dollar 4 dollar 0x01002620 0x0100263A'
#xmodmap -e 'keycode  14 = 5 percent 5 percent 0x01002620 0x0100263A'
#xmodmap -e 'keycode  15 = 6 asciicircum 6 asciicircum 0x01002620 0x0100263A'
#xmodmap -e 'keycode  16 = 7 ampersand 7 ampersand 0x01002620 0x0100263A'
#xmodmap -e 'keycode  17 = 8 asterisk 8 asterisk 0x01002620 0x0100263A'
#xmodmap -e 'keycode  18 = 9 parenleft 9 parenleft 0x01002620 0x0100263A'
#xmodmap -e 'keycode  19 = 0 parenright 0 parenright 0x01002620 0x0100263A'

The newer systems may requre xkbcomp used instead. Provide charaters like ®™°␈, →…‘’“”, and ☹ ☺ ™

#setxkbmap -print | xkbcomp - $DISPLAY
2> /dev/null xkbcomp - $DISPLAY << EOF
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)"       };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   {
                # looks in /usr/share/X11/xkb/symbols/gb amongst others
                # We can edit that file to make changes permanent, maybe use dpkg-divert first!
                # keys are unshift, shift, right alt, right alt and right alt shifted

                include "pc+gb(dvorak)+inet(evdev)+level3(ralt_switch)"
                key <AE01>  { [         1,     exclam,  U00AE,    trademark ] };
                key <AE02>  { [         2,   quotedbl,  U2192,    degree ] };
                key <AE03>  { [         3,   sterling,  U2026,    U2408 ] };
                key <AE04>  { [         4,     dollar,  EuroSign, U2620 ] };
                key <AE05>  { [         5,    percent,  U2639,    U1F63C ] };
                key <AE06>  { [         6, asciicircum, U263A,    U1F60A ] };
                key <AE07>  { [         7,  ampersand,  U2018,    U2620 ] };
                key <AE08>  { [         8,   asterisk,  U2019,    U2039 ] };
                key <AE09>  { [         9,  parenleft,  U201C,    U2018 ] };
                key <AE10>  { [         0, parenright,  U201D,    U2019 ] };
        };
        xkb_geometry  { include "pc(pc104)"     };
};
EOF