
|
|
|||
Loadkeys, DumpkeysBy Tony Lawrence2005-05-18
Loadkeys, Dumpkeys You can change the output of the console keyboard with loadkeys. It's an extremely powerful command, and the man page can be confusing, but for simple use (which is often all we need it for), it's very easy. For example, let's reprogram the F10 key: echo 'string F10 = "foo" ' | loadkeys See? That wasn't difficult. Oops, now what was the original value so we can put it back? Ahh, perhaps a little preparation would have been wise before changing that. The "dumpkeys" command does that: dumpkeys > myfullkeymap The "funcs-only" map is short: string F1 = "\033[[A" Yours will be different if you reprogrammed F10 above. Do this to put it back: echo 'string F10 = "\033[21~" ' | loadkeys If you had previously saved "funcsonlymap", you could put it all back with "loadkeys funcsonlymap" at any time, or simply use "loadkeys -d" The full key map is much longer and can be confusing. The first thing you have to understand is how keyboards really work: they actually send a keycode (also called "scancodes"). The "A" key on your keyboard actually sends 30, and F10 sends 68. You can use "showkey" to see what keycodes are really being sent (just stop typing briefly and showkey will exit). In the full keymap dump, you'll find: keycode 68 = F10 F22 Console_22 F34 And later in the same file you'll find: string F10 = "\033[21~" The last one is easy to understand, but what does the first part mean? Well, it defines key symbols, "keysms" in the "man keymaps" explanation. It's position dependent: F10 is the unshifted key, F22 is the shifted F10, but then we start getting confusing. The man page does a lousy job explaining it: Which of the actions bound to a given key is taken when it is pressed AltGr is the right hand Alt-Key, by the way. Later on, the man page helpfully tells us: To find out what keysyms there are available for use in keymaps, use So, going back to that key 68 definition, it's easy to see that F22 is the shifted F10, and indeed we can redefine it with: echo 'string F22 = "Foo" ' | loadkeys But if you try that with Console_22, you'll get an error message from loadkeys. That's because it is one of the "actions" the man page is so vague about. It's defining the action for the right hand alt key and the function key. I could change it by replacing the keymap definition: keycode 68 = F10 F22 F100 F34 And then set F100 to be what I want: echo 'string F100 = "Foo" ' | loadkeys And then Right Alt-F10 will send "Foo". That's fine. Or, I could leave it as it is and use it for what it is really intended for, but we'll save that for later. The next position (F34) should be (as I understand the man page ) Shift , Right Alt, and F10. It isn't. If I program F34, it's Control F10 that sends what I set F34 to. That makes no sense at all. Let's take it slowly: Okey-dokey. It's binary, calculated back from position, right? Seems to make sense. After F22, position One. which obviously matches Shift, we have Console_22 in position Two. That should mean that it matches the AltGr or Right Alt key and indeed it does: if I enable tty22 in /etc/inittab, the AltGr-F10 will switch me to tty22 on the console. The next position is Three and it's F34. I define F34 on the fly echo 'string F34 = "Key34" ' | loadkeys because it's undefined in my default keymap. I would expect, since it is position Three, that the modifiers would be Shift and Altgr - 2 + 1 equals 3, right? Nope. Actually, Control F10 sends "Key34" after this. How does THAT make any sense? It doesn't. And it gets more strange. If I modify that keymapping like this: keycode 68 = F10 F22 Console_22 F34 F100 F101 and define F34, F100, and F101, it then works exactly as I would expect it to! Right Alt F10 sends the F34 string, Control F10 sends the F100, and Shift Control F10 sends the F101 string.. So why does it work differently by adding two keysyms??? And then I look farther down the table and see more confusion. How the heck can ShiftL (which I assume means Left Shift) be a modifier weight if Shift already is? Do I assume that to use those positions you'd have to NOT define the ordinary shift combination? That might make sense, but the man page doesn't explain that. It is easy to get confused (obviously), so they also provide a shortcut: The "alt keycode 68 = Console_10" is a shorthand way of defining alt plus F10 without stringing out the first keycode line to nine columns. Without that, you'd need nine entries (you can use VoidSymbol as a place holder for key combinations you don't care about) and you'd need thirteen to define CTRL-ALT-F10. So at the command line you can also do: echo 'control alt keycode 68 = F100' | loadkeys That lets us redefine the key combinations but still doesn't tell us what the mysterious "Console_" entries mean. The "control alt keycode 68 = Console_10" obviously defines the key that will switch to the "F10" virtual console. Let's try changing it: echo 'control alt keycode 68 = Console_3' | loadkeys With that in place, CTRL-ALT-F10 will switch to tty3. What about Console_22? Yes, that's a virtual console too - as long as you enable tty22 in inittab. If you have enabled tty22, then with the default keymap shown above, the right alt key and F10 will switch you to a virtual console on tty22. There's more to keymaps, but this at least gets you started. Tutorial Pages: » Loadkeys, Dumpkeys © Copyright 2005 A.P. Lawrence
|
||||
| About the NetVisits, Inc Network | Write For Us | Advertise Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy. |
Visit other NetVisits, Inc. sites: |