Determining scancodes for obscure keyboard to modify keymap

Bill Campbell freebsd at celestial.com
Tue Feb 24 14:49:16 PST 2009


On Tue, Feb 24, 2009, Patrick Lamaizi?re wrote:
>Le Tue, 24 Feb 2009 14:28:54 -0700,
>carnage <carnagewashere at gmail.com>:
>
>> I'm wondering how to go about determining the scancodes for keys on
>> keypress.
>> 
>> I am looking to remap an apple usb keyboard (a1048).  It has F13-16, 3
>> volume control keys and an eject key but no scroll lock, num lock,
>> pause/break, etc.  I'm wondering how I would go about changing some
>> of these not so useful keys into useful keys.
>> 
>> The keymap files in /usr/share/syscons/keymaps seem easy enough to
>> modify but I am unsure of how to determine what the scancodes
>> associated with the actual keys on keypress are.
>
>I asked for this some times ago without any reply. Finally I added some
>printf in the kbd driver. I don't remember exactly where, I think it was
>in the function genkbd_keyaction() in kdb.c (something like printf("%i
>- ", keycode)
>
>That's ugly... Is there a better way to get the scancode?

As somebody else pointed out, xev is your friend.

I am attaching the .Xmodmap file I use on OS X to allow the
numeric keypad on the Microsoft 4000 natural keybaord to do the
Right Thing(tm) (e.g. send numbers when using python curses).

BTW:  the emacs stuff at the end is supposed to work, but I have
not been able to get it to work, but then I've never been able to
get my fingers around emacs either -- they've been doing vi for
25+ years, and seem to be untrainable.

Bill
-- 
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
Fax:            (206) 232-9186

A liberal is someone who feels a great debt to his fellow man, which
debt he proposes to pay off with your money. -- G Gordon L iddy
-------------- next part --------------
! keypad mappings for Apple with Microsoft Natural keyboard
keycode 91 = 1
keycode 90 = 0
keycode 92 = 2
keycode 93 = 3
keycode 94 = 4
keycode 95 = 5
keycode 96 = 6
keycode 97 = 7
keycode 99 = 8
keycode 100 = 9
keycode 73 = period
keycode 83 = slash
keycode 75 = asterisk
keycode 86 = minus
keycode 77 = plus
keycode 84 = Return
! Microsoft Ergonomic 4000
keycode 89 = equal
! emacs mapping keys to Alt
clear mod2
keycode 63 = Meta_L
keycode 66 = Meta_L
add mod2 = Meta_L


More information about the freebsd-questions mailing list