11

I am using a keyboard with the Fn key. This is on a laptop.

So my Fn + Up/Down/Left/Right keys are mapped to brightness/volume. I would much rather them be mounted to Page Up/Page Down and Home/End. And map the other 4 keys to these 2. The page Page Up/Page Down has Fn + them for Home/End. Its a shitty keyboard layout but I want to make it work.

Anyone knows how to figure out what the keycodes are and how to remap them?

Version: 10.04 x32

So here are some experiments:

Using xmodmap -pke I discovered that keycodes 122 = vol down, 123 = vol up. And I got all the info for Home/End/Page Up (next), Page Down (prior).

Now when using the vol up keys, there are no events being fired that xev can detect.

I can remap the volume keys to XF86AudioLowerVolume or XF86AudioRaiseVolume, but once I map those two to Home/End (respectively) they don't do anything. xev still does not pick up these events after a remap.

Remap: xmodmap -e "keycode 122 = Home"

Artur Meinild
  • 21,605
  • 21
  • 56
  • 89
Dmitriy Likhten
  • 1,334
  • 6
  • 14
  • 31

3 Answers3

8

Some laptop Fn key combinations are multimedia keys (appearing to the OS as ordinary keys with nonstandard codes), while others trigger ACPI events that eventually reach the OS, and some are just handled by the BIOS and never seen by the OS. The information paths are explained on the Hotkeys/Architecture page on the Ubuntu wiki, complete with diagrams.

The KeyTouch program should handle anything that is seen by the OS, and has a friendly GUI for describing your model and configuring what the keys should do (install the keytouch-editor package as well as keytouch).

If the OS can't see anything when you press the brightness keys, it could be because they're handled directly by the BIOS. The battle is not completely lost — it is in principle possible to hack the BIOS — but the difficulty level is considerably raised.

Gilles 'SO- stop being evil'
  • 59,745
  • 16
  • 131
  • 158
  • I get the error `keytouch-editor: No event devices are available in /dev/input/.` on launch – Jonathan Dec 27 '14 at 21:54
  • @JonathanLeaders You should ask a new question, explaining exactly how you ran the program. Be sure to mention which version of Ubuntu you're running. – Gilles 'SO- stop being evil' Dec 27 '14 at 22:15
  • 2
    sudo !! was all i had to do =p But keytouch editor can't recognize my keyboard anyway. Trying `xbindkeys -v` now but it says theres a conflict with another program but doens't say which pid – Jonathan Dec 27 '14 at 23:30
0

There is a program called xev that does what you require. I liked the tutorial on setting it up.

myusuf3
  • 33,569
  • 41
  • 88
  • 103
  • I tried using xmodmap before. Strangely enough I could remap the volume up key to the brightness up action. And the page up key to the end action. However I could never remap the volume up key to the page up action. It just would not execute, and vice versa. – Dmitriy Likhten Aug 16 '10 at 18:20
  • I tried xev, maps the page/home keys, does not even get events for the vol/brightness keys. – Dmitriy Likhten Aug 16 '10 at 18:31
  • 1
    that probably because these keys are mapped directly to graphic card or sound card :) – myusuf3 Aug 16 '10 at 18:56
  • 1
    @Dmitriy: Maybe some of the Fn key combinations produce ACPI events rather than keyboard events. Look in `/var/log/kern.log` if something appears when you press these key combinations. Even if nothing appears, there may be ACPI events that you can get to see if you use the right tools (sorry, I don't know what the right tools are). – Gilles 'SO- stop being evil' Aug 16 '10 at 19:45
  • @Gilles: Nothing appears in the kern log when pressing either key. Do I need some sort of debugging enabled? – Dmitriy Likhten Aug 16 '10 at 21:34
  • @Dmitriy: If nothing appears in either `kern.log` or `xev`, it's not a keyboard event. So it's likely to be an ACPI event. Try running `acpi_listen` and pressing a key. If nothing appears there either, try googling for your exact laptop model + ACPI, or catching the attention of someone who understands ACPI. – Gilles 'SO- stop being evil' Aug 16 '10 at 21:57
  • Nay, nothing in acpi_listen. – Dmitriy Likhten Aug 18 '10 at 14:54
  • 1
    The program that remaps is xmodmap; xev is just used to view events. –  Aug 19 '10 at 05:40
  • 3
    -1 dead link for the tutorial. Any chance you copied this info or is it lost forever? – Tom Brossman Jul 13 '12 at 05:42
-1

The Fn key combinations is not defined in software and can therefor not be redefined, so you need a soldering iron and some electronics knowhow!

LassePoulsen
  • 14,517
  • 8
  • 47
  • 59
  • What??? No I don't care about making the FN key different. Just re-map the events associated with the FN key. As in FN + Left = Volume Down event that the computer recognizes, I just want to change the effect of the event so it appears as if I pressed Home. I mean the keyboard layout is what defines what key does what, how do I modify that. – Dmitriy Likhten Aug 16 '10 at 17:44
  • 3
    I clearly didn't express my self clearly! But you cant change the predefined values. These combinations doesn't send signals to the OS but directly to the graphics-card/sound-card. – LassePoulsen Aug 16 '10 at 18:20
  • Oh! Though the OS does recognize that the brightness is changing and the volume too to show this information in the GUI. – Dmitriy Likhten Aug 16 '10 at 19:05
  • 3
    @Source Lab: On most laptops produced this century or thereabouts, all recognized Fn key combinations either trigger keyboard events or ACPI events. Keyboard events go to the OS; ACPI events can be handled by the BIOS but the OS can intercept them. – Gilles 'SO- stop being evil' Aug 16 '10 at 19:42
  • @Gilles Oh. I didn't know that newer computers will send keyboard events. – LassePoulsen Aug 16 '10 at 20:15
  • @Gilles this sounds much more plausable. I really hope someone here knows how to re-map this. – Dmitriy Likhten Aug 16 '10 at 21:33
  • @Dmitrly: The volume-related keys are sent to the OS, but where do you see the screen brightness displayed in Ubuntu? How do you know the OS is recognizing that? –  Aug 19 '10 at 05:42
  • @Roger: Good point. There is no indication about brightness. I think I remapped the up/down keys to inverse each other once to see if it worked, a month or 2 ago when I experimented last. – Dmitriy Likhten Aug 24 '10 at 17:52