From owner-freebsd-questions@FreeBSD.ORG Thu Dec 16 06:11:05 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CA3B216A4CE for ; Thu, 16 Dec 2004 06:11:05 +0000 (GMT) Received: from smtp.io.com (smtp.io.com [206.224.87.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id D905843D1D for ; Thu, 16 Dec 2004 06:11:04 +0000 (GMT) (envelope-from eighner@io.com) Received: from io.com (aus-as1-49.io.com [199.170.90.49]) by smtp.io.com (8.13.1/8.13.1) with SMTP id iBG6AxEW030557; Thu, 16 Dec 2004 00:11:00 -0600 (CST) (envelope-from eighner@io.com) Date: Thu, 16 Dec 2004 00:07:08 -0600 (CST) From: Lars Eighner To: John Conover In-Reply-To: <20041215214746.5288.qmail@rahul.net> Message-ID: <20041215224126.X54401@goodwill.io.com> References: <20041215214746.5288.qmail@rahul.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: ClamAV 0.80/617/Sun Dec 5 09:25:39 2004 clamav-milter version 0.80j on smtp.io.com X-Virus-Status: Clean cc: freebsd-questions@freebsd.org Subject: Re: ALT key on console25? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Dec 2004 06:11:05 -0000 On Wed, 15 Dec 2004, John Conover wrote: > > Is it possible to make the ALT key work on console25? The console keyboard is easily mappable. Assuming you have a normal PC (and not some Sparc or Alpha thing about which I know nothing), your ALT key should work right out of the box. The problem, if you have a problem, is that it may not do quiet what you want. Now there are two different things that people may mean when they say they want ALT characters. Some people (and applications) want ALT- to mean an eight-bit character, which is simply the 7-bit character with the 8th bit set. Other people (and applications) want ALT- to send a string composed of the escape character followed by the 7-bit character. You can get either behavior (or if you have a spare key, like the Windoz key) you can get both. Another possible problem is with ALT-, which for the numbered F keys are usually used to switch consoles, but which can easily be adjust to do the norm ANSI keyboard thing that you expect with a PC. First, to get ALT- to send the eight-bit character, use the emacs keyboard. To get the -character behavior you must remap the ALT keys to "meta" (or use a spare key like Windoz as the "meta" key. To get the ALT-Fn keys to send the ANSI keys ( -[-w through -[-{ ) you just have to switch some key definitions around. I will now demonstrate how each of these things works: The keyboard maps reside in /usr/share/syscons/keymaps. The keymap you want to use is set in /etc/rc.conf with a line like this: keymap="us.emacs" To be effective, this line must be the last of similar lines in rc.conf. (Essentially, the defaults are in /etc/default - don't mess with them - and sysinstall and you use /etc/rc.conf to make changes, and the last changes in this file win.) Changes made in rc.conf will not be effective until or unless you reboot. You can use kbdcontrol to change keymaps in your current session. Simply changing to the emacs keyboard will get the behavoir of sending 8-bit characters for ALT- Here is a part of the us-iso keyboard you probably installed: # alt # scan cntrl alt alt cntrl lock # code base shift cntrl shift alt shift cntrl shift state # ------------------------------------------------------------------ 000 nop nop nop nop nop nop nop nop O 001 esc esc esc esc esc esc debug esc O 002 '1' '!' nop nop '1' '!' nop nop O 003 '2' '@' nul nul '2' '@' nul nul O See, ALT-1 simply sends 1, and ALT-! simply sends !, and that is not what you want. Here is the same part of the us-emacs keyboard: # alt # scan cntrl alt alt cntrl lock # code base shift cntrl shift alt shift cntrl shift state # ------------------------------------------------------------------ 000 nop nop nop nop nop nop nop nop O 001 esc esc esc esc esc esc esc esc O 002 '1' '!' nop nop 177 161 nop nop O 003 '2' '@' nul nul 178 192 128 128 O Now see, 1 sends 1 which is character code 49, but ALT-1 sends 177, which is 49 + 128 - or in other words 1 with the 8th bit set. So if that is what you want (and it is probably what you expect on a PC), just switch to the emacs keyboard). But if you want ALT- to send -, what you want is called a meta key. One of the best ways to get a meta key is to map the Windoz keys to meta. 105 meta fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 O 106 meta fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 O 107 esc fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 O This maps the Windoz keys to meta (and makes the Menu key an extra esc key in case you are too lazy to reach all the way up there to hit the usual esc key. If you don't have Windoz keys get a new keyboard - they are cheap - or remap one or the other of the ALT keys. 056 lalt lalt lalt lalt lalt lalt lalt lalt O 093 ralt ralt ralt ralt ralt ralt ralt ralt O You can change whichever of the lalt or ralt keys to meta. Oh, yeah, make these change with a flat ascii edit, not a word processor, and probably you should save the distribution keyboard somewhere (like us.emacs.kbd.dist) before you edit). You probably do not want to make all the alt keys into meta. So that gets you 1) ALT- sends 8-bit character, and 2) META- sends -. Finally we come to the function keys known as F1, F2, ... F12. Again I am assuming an ordinary PC with a more or less PC compatible keyboard attached. Here's the pertenant part of the us.emacs keyboard (with a bunch of stuff skipped so you can easily see the headers): # alt # scan cntrl alt alt cntrl lock # code base shift cntrl shift alt shift cntrl shift state # ------------------------------------------------------------------ 000 nop nop nop nop nop nop nop nop O # skipped stuff 059 fkey01 fkey13 fkey25 fkey37 scr01 scr11 scr01 scr11 O 060 fkey02 fkey14 fkey26 fkey38 scr02 scr12 scr02 scr12 O 061 fkey03 fkey15 fkey27 fkey39 scr03 scr13 scr03 scr13 O 062 fkey04 fkey16 fkey28 fkey40 scr04 scr14 scr04 scr14 O 063 fkey05 fkey17 fkey29 fkey41 scr05 scr15 scr05 scr15 O 064 fkey06 fkey18 fkey30 fkey42 scr06 scr16 scr06 scr16 O 065 fkey07 fkey19 fkey31 fkey43 scr07 scr07 scr07 scr07 O 066 fkey08 fkey20 fkey32 fkey44 scr08 scr08 scr08 scr08 O 067 fkey09 fkey21 fkey33 fkey45 scr09 scr09 scr09 scr09 O 068 fkey10 fkey22 fkey34 fkey46 scr10 scr10 scr10 scr10 O # stuff skipped between f10 and f11 087 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O 088 fkey12 fkey24 fkey36 fkey48 scr12 scr12 scr12 scr12 O What this does is make ALT-Fx switch to virtual terminal x. Probably you want ALT-Fx to send the ansi codes -[-w through -[-{. These codes are sent by fkey37 through fkey48. All you have to do is switch fkey37 with scr01, fkey38 with scr02, etc. Like this: # alt # scan cntrl alt alt cntrl lock # code base shift cntrl shift alt shift cntrl shift state # ------------------------------------------------------------------ #Stuff skipped 059 fkey01 fkey13 fkey25 scr01 fkey37 scr11 scr01 scr11 O 060 fkey02 fkey14 fkey26 scr02 fkey38 scr12 scr02 scr12 O 061 fkey03 fkey15 fkey27 scr03 fkey39 scr13 scr03 scr13 O 062 fkey04 fkey16 fkey28 scr04 fkey40 scr14 scr04 scr14 O 063 fkey05 fkey17 fkey29 scr05 fkey41 scr15 scr05 scr15 O 064 fkey06 fkey18 fkey30 scr06 fkey42 scr16 scr06 scr16 O 065 fkey07 fkey19 fkey31 scr07 fkey43 scr07 scr07 scr07 O 066 fkey08 fkey20 fkey32 scr08 fkey44 scr08 scr08 scr08 O 067 fkey09 fkey21 fkey33 scr09 fkey45 scr09 scr09 scr09 O 068 fkey10 fkey22 fkey34 scr10 fkey46 scr10 scr10 scr10 O #stuff skipped 087 fkey11 fkey23 fkey35 scr11 fkey47 scr11 scr11 scr11 O 088 fkey12 fkey24 fkey36 scr12 fkey48 scr12 scr12 scr12 O And that's that. Bonus: Make ALT-tab and CTL-tab rotate through the virtual screens: 015 ht ht nscr ht pscr 137 137 137 O Bonus bonus: Make xterm work more or less like your new console and make the delete keys work properly: Add this to your .Xdefaults file: !! xterm keymappings *XTerm*VT100.translations: #override \n\ NoneF1: string(0x1b) string("[M") \n\ NoneF2: string(0x1b) string("[N") \n\ NoneF3: string(0x1b) string("[O") \n\ NoneF4: string(0x1b) string("[P") \n\ NoneF5: string(0x1b) string("[Q") \n\ NoneF6: string(0x1b) string("[R") \n\ NoneF7: string(0x1b) string("[S") \n\ NoneF8: string(0x1b) string("[T") \n\ NoneF9: string(0x1b) string("[U") \n\ NoneF10: string(0x1b) string("[V") \n\ NoneF11: string(0x1b) string("[W") \n\ NoneF12: string(0x1b) string("[X") \n\ NoneInsert: string(0x1b) string("[L") \n\ ShiftF1: string(0x1b) string("[Y") \n\ ShiftF2: string(0x1b) string("[Z") \n\ ShiftF3: string(0x1b) string("[a") \n\ ShiftF4: string(0x1b) string("[b") \n\ ShiftF5: string(0x1b) string("[c") \n\ ShiftF6: string(0x1b) string("[d") \n\ ShiftF7: string(0x1b) string("[e") \n\ ShiftF8: string(0x1b) string("[f") \n\ ShiftF9: string(0x1b) string("[g") \n\ ShiftF10: string(0x1b) string("[h") \n\ ShiftF11: string(0x1b) string("[i") \n\ ShiftF12: string(0x1b) string("[j") \n\ CtrlF1: string(0x1b) string("[k") \n\ CtrlF2: string(0x1b) string("[l") \n\ CtrlF3: string(0x1b) string("[m") \n\ CtrlF4: string(0x1b) string("[n") \n\ CtrlF5: string(0x1b) string("[o") \n\ CtrlF6: string(0x1b) string("[p") \n\ CtrlF7: string(0x1b) string("[q") \n\ CtrlF8: string(0x1b) string("[r") \n\ CtrlF9: string(0x1b) string("[s") \n\ CtrlF10: string(0x1b) string("[t") \n\ CtrlF11: string(0x1b) string("[u") \n\ CtrlF12: string(0x1b) string("[v") \n\ AltF1: string(0x1b) string("[w") \n\ AltF2: string(0x1b) string("[x") \n\ AltF3: string(0x1b) string("[y") \n\ AltF4: string(0x1b) string("[z") \n\ AltF5: string(0x1b) string("[@") \n\ AltF6: string(0x1b) string("[[") \n\ AltF7: string(0x1b) string("[ ") \n\ AltF8: string(0x1b) string("[]") \n\ AltF9: string(0x1b) string("[^") \n\ AltF10: string(0x1b) string("[_") \n\ AltF11: string(0x1b) string("[`") \n\ AltF12: string(0x1b) string("[{") \n\ Metaa: string(0x1b) string("a") \n\ Metab: string(0x1b) string("b") \n\ Metac: string(0x1b) string("c") \n\ Metad: string(0x1b) string("d") \n\ Metae: string(0x1b) string("e") \n\ Metaf: string(0x1b) string("f") \n\ Metag: string(0x1b) string("g") \n\ Metah: string(0x1b) string("h") \n\ Metai: string(0x1b) string("i") \n\ Metaj: string(0x1b) string("j") \n\ Metak: string(0x1b) string("k") \n\ Metal: string(0x1b) string("l") \n\ Metam: string(0x1b) string("m") \n\ Metan: string(0x1b) string("n") \n\ Metao: string(0x1b) string("o") \n\ Metap: string(0x1b) string("p") \n\ Metaq: string(0x1b) string("q") \n\ Metar: string(0x1b) string("r") \n\ Metas: string(0x1b) string("s") \n\ Metat: string(0x1b) string("t") \n\ Metau: string(0x1b) string("u") \n\ Metav: string(0x1b) string("v") \n\ Metaw: string(0x1b) string("w") \n\ Metax: string(0x1b) string("x") \n\ Metay: string(0x1b) string("y") \n\ Metaz: string(0x1b) string("z") \n\ Meta1: string(0x1b) string("1") \n\ Meta2: string(0x1b) string("2") \n\ Meta3: string(0x1b) string("3") \n\ Meta4: string(0x1b) string("4") \n\ Meta5: string(0x1b) string("5") \n\ Meta6: string(0x1b) string("6") \n\ Meta7: string(0x1b) string("7") \n\ Meta8: string(0x1b) string("8") \n\ Meta9: string(0x1b) string("9") \n\ Meta0: string(0x1b) string("0") \n\ MetaEscape: string(0x1b) string(0x1b) \n\ Metaexclam: string(0x1b) string("!") \n\ Metaat: string(0x1b) string("@") \n\ Metanumbersign: string(0x1b) string("#") \n\ Metadollar: string(0x1b) string("$") \n\ Metapercent: string(0x1b) string("%") \n\ Metaasciicircum: string(0x1b) string("^") \n\ Metaampersand: string(0x1b) string("&") \n\ Metaasterisk: string(0x1b) string("*") \n\ Metaparenleft: string(0x1b) string("(") \n\ Metaparenright: string(0x1b) string(")") \n\ Metaminus: string(0x1b) string("-") \n\ Metaunderscore: string(0x1b) string("_") \n\ Metaequal: string(0x1b) string("=") \n\ Metaplus: string(0x1b) string("+") \n\ Metabracketleft: string(0x1b) string("[") \n\ Metabraceleft: string(0x1b) string("{") \n\ Metabracketright: string(0x1b) string("]") \n\ Metabraceright: string(0x1b) string("}") \n\ Metasemicolon: string(0x1b) string(";") \n\ Metacolon: string(0x1b) string(";") \n\ Metaapostrophe: string(0x1b) string("0x27") \n\ Metaquotedbl: string(0x1b) string("0x22") \n\ Metagrave: string(0x1b) string("9x96") \n\ Metaasciitilde: string(0x1b) string("~") \n\ Metabackslash: string(0x1b) string("0x92") \n\ Metabar: string(0x1b) string("|") \n\ Metacomma: string(0x1b) string(",") \n\ Metaless: string(0x1b) string("<") \n\ Metaperiod: string(0x1b) string(".") \n\ Metagreater: string(0x1b) string(">") \n\ Metaslash: string(0x1b) string("/") \n\ Metaquestion: string(0x1b) string("?") \n\ Delete: string(0x7f) \n\ KP_Delete: string(0x7f) \n\ -- Lars Eighner eighner@io.com -finger for geek code- http://www.io.com/~eighner/index.html 8800 N IH35 APT 1191 AUSTIN TX 78753-5266