mapping external keyboard keys to mac keys
Solution 1:
ControllerMate does this. At work I use the Microsoft Natural ergonomic keyboard and a Logitech mouse. ControllerMate has hardware profiles for both, and I have many of the MS-specific keys remapped to other functions.
Like yours, my keyboard also has an otherwise useless Mail button. With Controllermate open, if I press the Mail button while viewing the Microsoft keyboard profile, the list of available key sequences automatically jumps to the one it just received. You can then program that key to do whatever you like, even when ControllerMate isn't open.
Solution 2:
I think the answer about ControllerMate is a good one, but since you asked in a comment about a configuration file, I'll mention that the most powerful, "raw" way to configure your keyboard settings is by creating a custom keyboard layout. I would guess that this is how apps like ControllerMate modify keyboard keys, but I can't say that for sure.
You can use an online generator for this purpose (it's old, but the .keylayout
files it generates still work under Snow Leopard) or a GUI like Ukelele (free).
When doing it this way, you would add the resulting .keylayout
XML file to /Library/Keyboard Layouts
(for use by all users) or ~/Library/Keyboard Layouts
(for use by only the current user). Then you would enable the custom layout in System Preferences -> Language & Text -> Input Sources.
For your third-party keyboard, it would still be tricky to find out the key code in a given mapSet for those "useless" keys for "Back", "Forward", "Mail", etc. Personally, I would go with a GUI program that allows me to "press and set" so there's no extra research or guesswork on my part.
So in short, I am not saying that this method is easier or even more powerful than using an app like ControllerMate, but it should at least help explain how keyboards can be re-mapped under OS X without a "middleman" program that has to stay running in the background.
Solution 3:
I know this is an old question, but future generations might like to know about a more recent tool. It's called Karabiner and can remap tons of things, and has defaults for mapping the F* keys to their Appley equivalents.