I decided to log this post as a complement to another one called Keyboard - Layouts where I demonstrated how to fully reconfigure the keyboard for console terminals without delving into very complex system APIs. In doing so I'll add the benefit of getting rid of spurious Sun-specific key-stations and enabling a few others that will be useful in achieving better text cursor control within console terminals.
I'll try not to repeat myself believing that any omissions on this post are fully explained on the previous one I've mentioned: Keyboard - Layouts.
Any standard hardware should do but I shall take a legacy PS/2 Dell keyboard model RT7D20 (US) as an example, which layout is a pretty standard one:
The following are the contents of the file layout_DELL-RT7D20-US located at /usr/share/lib/keytables/type_6: and aliased (via a symbolic link) as layout_201 (which I've chosen following the guidelines found on the system file kbd_layouts at the same directory):
NOTE
I won't try to highlight changes from the Keyboard - Layouts post.#
But I try to ease readability by dimming the comments.
# Type 6 (USB) layout for DELL RT7D20 (US)
#
# This layout forms an extensive baseline.
# It provides no complex dead-keys or Alt_Gr sequences.
#
# Notes for function keys (BFn, TFn, LFn and RFn):
# F1 ... F12 ... F16
# L ESC[192z ... ESC[203z ... ESC[207z
# R ESC[208z ... ESC[219z ... ESC[223z
# T ESC[224z ... ESC[235z ... ESC[239z
# B ESC[240z ... ESC[251z ... ESC[255z
#
# In theory I could use escape sequences similar to those above.
# Unfortunately, these would result in a "too many strings" error.
# It's important to know how to capture these in BASH READLINE.
# Whithin ~/.inputrc they should be referenced as "\e[XXXz": command/macro
#
# Still availables:
# - functions:
# - keystations:
# - some ctrl / shift actions for keystations:
# -- 30 to 39, 40 to 44, 45 to 49, 79 to 82
#
key 0 all hole
key 1 all hole
key 2 all hole
key 3 all nonl
#
key 4 base a shift A caps A ctrl ^A altg nop numl nonl up nop
key 5 base b shift B caps B ctrl ^B altg nop numl nonl up nop
key 6 base c shift C caps C ctrl ^C altg nop numl nonl up nop
key 7 base d shift D caps D ctrl ^D altg nop numl nonl up nop
key 8 base e shift E caps E ctrl ^E altg nop numl nonl up nop
key 9 base f shift F caps F ctrl ^F altg nop numl nonl up nop
key 10 base g shift G caps G ctrl ^G altg nop numl nonl up nop
key 11 base h shift H caps H ctrl ^H altg nop numl nonl up nop
key 12 base i shift I caps I ctrl ^I altg nop numl nonl up nop
key 13 base j shift J caps J ctrl ^J altg nop numl nonl up nop
key 14 base k shift K caps K ctrl ^K altg nop numl nonl up nop
key 15 base l shift L caps L ctrl ^L altg nop numl nonl up nop
key 16 base m shift M caps M ctrl ^M altg nop numl nonl up nop
key 17 base n shift N caps N ctrl ^N altg nop numl nonl up nop
key 18 base o shift O caps O ctrl ^O altg nop numl nonl up nop
key 19 base p shift P caps P ctrl ^P altg nop numl nonl up nop
key 20 base q shift Q caps Q ctrl ^Q altg nop numl nonl up nop
key 21 base r shift R caps R ctrl ^R altg nop numl nonl up nop
key 22 base s shift S caps S ctrl ^S altg nop numl nonl up nop
key 23 base t shift T caps T ctrl ^T altg nop numl nonl up nop
key 24 base u shift U caps U ctrl ^U altg nop numl nonl up nop
key 25 base v shift V caps V ctrl ^V altg nop numl nonl up nop
key 26 base w shift W caps W ctrl ^W altg nop numl nonl up nop
key 27 base x shift X caps X ctrl ^X altg nop numl nonl up nop
key 28 base y shift Y caps Y ctrl ^Y altg nop numl nonl up nop
key 29 base z shift Z caps Z ctrl ^Z altg nop numl nonl up nop
#
key 30 base 1 shift ! caps 1 ctrl nop altg nop numl nonl up nop
key 31 base 2 shift @ caps 2 ctrl nop altg nop numl nonl up nop
key 32 base 3 shift # caps 3 ctrl nop altg nop numl nonl up nop
key 33 base 4 shift $ caps 4 ctrl nop altg nop numl nonl up nop
key 34 base 5 shift % caps 5 ctrl nop altg nop numl nonl up nop
key 35 base 6 shift ^ caps 6 ctrl nop altg nop numl nonl up nop
key 36 base 7 shift & caps 7 ctrl nop altg nop numl nonl up nop
key 37 base 8 shift * caps 8 ctrl nop altg nop numl nonl up nop
key 38 base 9 shift ( caps 9 ctrl nop altg nop numl nonl up nop
key 39 base 0 shift ) caps 0 ctrl nop altg nop numl nonl up nop
#
# - For Backspace I have to use '\177' (octal) and not '\b':
# -- Note that \177 (octal) = 7F (hexa) = 127 (decimal)
# -- The terminal will see \177 as ^?, which is the correct thing.
# -- The \b would be seen as ^H which isn't the default "stty erase".
# -- This is important for the correct login prompt behavior
# of the backspace (keystation 42)
#
# Note: The escape sequence strings begin with ^[
# which in VI/VIM is generated while in insert mode
# by pressing ^V and then the Esc key.
# copy-and-paste may not work.
#
key 40 all '\r' ctrl "^[[187z" numl nonl up nop
key 41 all ^[ ctrl "^[[188z" numl nonl up nop
key 42 all '\177' ctrl "^[[189z" numl nonl up nop
key 43 all '\t' ctrl "^[[190z" numl nonl up nop
key 44 all ' ' ctrl "^[[191z" numl nonl up nop
#
key 45 base - shift _ caps - ctrl nop altg nop numl nonl up nop
key 46 base = shift + caps = ctrl nop altg nop numl nonl up nop
key 47 base [ shift { caps [ ctrl nop altg nop numl nonl up nop
key 48 base ] shift } caps ] ctrl nop altg nop numl nonl up nop
key 49 base '\\' shift | caps '\\' ctrl nop altg nop numl nonl up nop
#
key 50 same as 49
#
key 51 base ; shift : caps ; ctrl nop altg nop numl nonl up nop
key 52 base '\'' shift '"' caps '\'' ctrl nop altg nop numl nonl up nop
key 53 base ` shift ~ caps ` ctrl nop altg nop numl nonl up nop
key 54 base , shift < caps , ctrl nop altg nop numl nonl up nop
key 55 base . shift > caps . ctrl nop altg nop numl nonl up nop
key 56 base / shift ? caps / ctrl nop altg nop numl nonl up nop
#
key 57 all shiftkeys+capslock
#
# keystations 58 thru 69 are F1 thru F12 respectively
# Decision:
# - Fn = bf(n)
# - Shift + Fn = lf(n)
# - Ctrl + Fn = tf(n) --> to not conflict with VT-n shortcuts
#
key 58 base bf(1) shift lf(1) caps bf(1) ctrl tf(1) altg nop numl nonl up nop
key 59 base bf(2) shift lf(2) caps bf(2) ctrl tf(2) altg nop numl nonl up nop
key 60 base bf(3) shift lf(3) caps bf(3) ctrl tf(3) altg nop numl nonl up nop
key 61 base bf(4) shift lf(4) caps bf(4) ctrl tf(4) altg nop numl nonl up nop
key 62 base bf(5) shift lf(5) caps bf(5) ctrl tf(5) altg nop numl nonl up nop
key 63 base bf(6) shift lf(6) caps bf(6) ctrl tf(6) altg nop numl nonl up nop
key 64 base bf(7) shift lf(7) caps bf(7) ctrl tf(7) altg nop numl nonl up nop
key 65 base bf(8) shift lf(8) caps bf(8) ctrl tf(8) altg nop numl nonl up nop
key 66 base bf(9) shift lf(9) caps bf(9) ctrl tf(9) altg nop numl nonl up nop
key 67 base bf(10) shift lf(10) caps bf(10) ctrl tf(10) altg nop numl nonl up nop
key 68 base bf(11) shift lf(11) caps bf(11) ctrl tf(11) altg nop numl nonl up nop
key 69 base bf(12) shift lf(12) caps bf(12) ctrl tf(12) altg nop numl nonl up nop
#
# PtrScn/SysRq=70, ScrollLock=71, Pause/Break=72, Ins=73, Home=74, PgUp=75, Del=76, End=77, PgDn=78
# Decisions:
# - For PrtScn, just use it as F13 similarly as above.
# - For ScrollLock, use F16, for Pause, use Shift-F16, for Break, use ^F16.
# - For the other special keys I'll have to use RFn keys.
# At first I'm interested only on Ctrl modifications.
#
key 70 base bf(13) shift lf(13) caps bf(13) ctrl tf(13) altg nop numl nonl up nop
key 71 all bf(16) altg nop numl nonl up nop
key 72 all lf(16) ctrl tf(16) altg nop numl nonl up nop
#
key 73 all rf(1) ctrl rf(2) numl nonl up nop
key 74 all rf(3) ctrl rf(4) numl nonl up nop
key 75 all rf(5) ctrl rf(6) numl nonl up nop
key 76 all rf(7) ctrl rf(8) numl nonl up nop
key 77 all rf(9) ctrl rf(10) numl nonl up nop
key 78 all rf(11) ctrl rf(12) numl nonl up nop
#
key 79 all string+rightarrow ctrl rf(13) numl nonl up nop
key 80 all string+leftarrow ctrl rf(14) numl nonl up nop
key 81 all string+downarrow ctrl rf(15) numl nonl up nop
key 82 all string+uparrow ctrl rf(16) numl nonl up nop
#
key 83 all shiftkeys+numlock
#
# This keyboard has no padequal or padsep
#
key 84 all hole numl padslash up nop
key 85 all hole numl padstar up nop
key 86 all hole numl padminus up nop
key 87 all hole numl padplus up nop
key 88 all hole numl padenter up nop
key 89 all rf(9) ctrl rf(10) numl pad1
key 90 all string+downarrow ctrl rf(15) numl pad2
key 91 all rf(11) ctrl rf(12) numl pad3
key 92 all string+leftarrow ctrl rf(14) numl pad4
key 93 all hole numl pad5 up nop
key 94 all string+rightarrow ctrl rf(13) numl pad6
key 95 all rf(3) ctrl rf(4) numl pad7
key 96 all string+uparrow ctrl rf(16) numl pad8
key 97 all rf(5) ctrl rf(6) numl pad9
key 98 all rf(1) ctrl rf(2) numl pad0
key 99 all rf(7) ctrl rf(8) numl paddot
#
key 100 all hole
#
# Keystation 101 is Menu
# Decision:
# - For now, use as F14
#
key 101 base bf(14) shift lf(14) caps bf(14) ctrl tf(14) altg nop numl nonl up nop
#
key 102 all hole
key 103 all hole
key 104 all hole
key 105 all hole
key 106 all hole
key 107 all hole
key 108 all hole
key 109 all hole
key 110 all hole
key 111 all hole
key 112 all hole
key 113 all hole
key 114 all hole
key 115 all hole
key 116 all hole
key 117 all hole
key 118 all hole
key 119 all hole
key 120 all hole
key 121 all hole
key 122 all hole
key 123 all hole
key 124 all hole
key 125 all hole
#
key 126 all error numl error up hole
key 127 all idle numl idle up reset
#
key 128 all hole
key 129 all hole
key 130 all hole
key 131 all hole
key 132 all hole
key 133 all hole
key 134 all hole
key 135 all hole
key 136 all hole
key 137 all hole
key 138 all hole
key 139 all hole
key 140 all hole
key 141 all hole
key 142 all hole
key 143 all hole
key 144 all hole
key 145 all hole
key 146 all hole
key 147 all hole
key 148 all hole
key 149 all hole
key 150 all hole
key 151 all hole
key 152 all hole
key 153 all hole
key 154 all hole
key 155 all hole
key 156 all hole
key 157 all hole
key 158 all hole
key 159 all hole
key 160 all hole
key 161 all hole
key 162 all hole
key 163 all hole
key 164 all hole
key 165 all hole
key 166 all hole
key 167 all hole
key 168 all hole
key 169 all hole
key 170 all hole
key 171 all hole
key 172 all hole
key 173 all hole
key 174 all hole
key 175 all hole
key 176 all hole
key 177 all hole
key 178 all hole
key 179 all hole
key 180 all hole
key 181 all hole
key 182 all hole
key 183 all hole
key 184 all hole
key 185 all hole
key 186 all hole
key 187 all hole
key 188 all hole
key 189 all hole
key 190 all hole
key 191 all hole
key 192 all hole
key 193 all hole
key 194 all hole
key 195 all hole
key 196 all hole
key 197 all hole
key 198 all hole
key 199 all hole
key 200 all hole
key 201 all hole
key 202 all hole
key 203 all hole
key 204 all hole
key 205 all hole
key 206 all hole
key 207 all hole
key 208 all hole
key 209 all hole
key 210 all hole
key 211 all hole
key 212 all hole
key 213 all hole
key 214 all hole
key 215 all hole
key 216 all hole
key 217 all hole
key 218 all hole
key 219 all hole
key 220 all hole
key 221 all hole
key 222 all hole
key 223 all hole
#
key 224 all shiftkeys+leftctrl up shiftkeys+leftctrl
key 225 all shiftkeys+leftshift up shiftkeys+leftshift
key 226 all shiftkeys+alt up shiftkeys+alt
#
# Keystation 227 is LeftSuper (Win)
# Wondered about: "all compose numl nonl up nop"
# Decision:
# - For now, use as F15
#
key 227 base bf(15) shift lf(15) caps bf(15) ctrl tf(15) altg nop numl nonl up nop
#
key 228 all shiftkeys+rightctrl up shiftkeys+rightctrl
key 229 all shiftkeys+rightshift up shiftkeys+rightshift
#
key 230 same as 226
key 231 same as 227
#
key 231 all hole
key 232 all hole
key 233 all hole
key 234 all hole
key 235 all hole
key 236 all hole
key 237 all hole
key 238 all hole
key 239 all hole
key 240 all hole
key 241 all hole
key 242 all hole
key 243 all hole
key 244 all hole
key 245 all hole
key 246 all hole
key 247 all hole
key 248 all hole
key 249 all hole
key 250 all hole
key 251 all hole
key 252 all hole
key 253 all hole
key 254 all hole
Similarly to what's explained to the end of Keyboard - Layouts I'll adjust the contents of kbd_layouts as following:
...
UK-English=32
US-English=33
US-English-DELL-RT7D20=513
The persistence of configuration is done in the same way already presented on Keyboard - Layouts, as well as the last examples of optional temporary "layout fragments" tweaks.