Talk:How to get special keys to work

From ThinkWiki
Jump to: navigation, search

The xmodmap step doesn't seem to work when using the "kdb" driver of xorg. Here are the changes I needed to make to my setup to get the "back" and "forward" keys to work (in diff -u format);

--- xkb/symbols/inet.oud        2004-12-01 08:36:04.000000000 +0100
+++ xkb/symbols/inet    2005-03-08 19:59:32.587636120 +0100
@@ -1875,6 +1875,16 @@
     key <I76>  {       [ XF86AudioLowerVolume  ]       };
+// IBM ThinkPad 41 Internet Keys
+partial alphanumeric_keys
+xkb_symbols "tp41" {
+    name[Group1]= "IBM ThinkPad 41 Internet Keys";
+    key <I69>  {       [ F22           ]       };
+    key <I6A>  {       [ F21           ]       };
 // Trust
 partial alphanumeric_keys
--- xkb/rules/xorg.lst.oud      2004-12-01 08:36:05.000000000 +0100
+++ xkb/rules/xorg.lst  2005-03-07 20:55:21.000000000 +0100
@@ -97,6 +97,7 @@
   sven         SVEN Ergonomic 2500
   symplon      Symplon PaceBook (tablet PC)
   toshiba_s3000        Toshiba Satellite S3000
+  tp41         IBM ThinkPad 41 Internet Keys
   trust                Trust Wireless Keyboard Classic
   trustda      Trust Direct Access Keyboard
   yahoo                Yahoo! Internet Keyboard
--- xkb/rules/xorg.oud  2004-12-01 08:36:05.000000000 +0100
+++ xkb/rules/xorg      2005-03-07 20:45:59.000000000 +0100
@@ -120,7 +120,7 @@
               qtronix \
               samsung4500 samsung4510 \
               sk1300 sk2500 sk6200 sk7100 \
-              sven symplon toshiba_s3000 trust trustda yahoo
+              sven symplon toshiba_s3000 tp41 trust trustda yahoo

 ! model         =       symbols
   $inetkbds     =       +inet(%m)
--- xkb/rules/xorg.xml.oud      2004-12-01 08:36:05.000000000 +0100
+++ xkb/rules/xorg.xml  2005-03-07 20:52:35.000000000 +0100
@@ -975,6 +975,13 @@
+        <name>tp41</name>
+        <description>IBM Thinkpad 41 Internet Keys</description>
+        <description xml:lang="nl">IBM ThinkPad 41 internet toetsen</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
         <description>Trust Wireless Keyboard Classic</description>
         <description xml:lang="fr">clavier classique Trust Wireless</description> 

Do not forget to add something like "+inet(tp41)" to /etc/X11/xorg.conf:

       Option      "XkbLayout" "us_intl+inet(tp41)"

I've filled a bug to freedesktop bugzilla, which has been applied. It adds inet(thinkpad) symbols with <I69>/<I6A> keys and adds thinkpad to $inetkbds list. So, Forward/Back keys will work out-of-box with thinkpad XkbModel. However, thinkpadintl model is not supported... --Raorn 13:25, 27 January 2007 (CET)

Not T41 specific

These keys are hardly T41 specific, they can also be found on the T30, T40, T42 and I'm sure several other ThinkPads in the X, R and G lineup.

Actually, the above patches could be completed with the information of the other special keys found on some Thinkpads (which is listed in How_to_get_special_keys_to_work#xmodmap_configuration) and submitted as a request for enhancement with xorg's bugzilla. However, firefox doesn't yet recognize keysyms like XF86Back, XF86Forward, so then firefox still needs to be patched manually (unless an enhancement is requested for firefox too).

XF86Back in Firefox

I found that XF86Back and XF86Forward work for me with firefox. I was able to use the following in /usr/lib/firefox/chrome/browser/content/browser/browser.xul

<key id="goBackKb" keycode="XF86Back" command="Browser:Back" />
<key id="goForwardKb" keycode="XF86Forward" command="Browser:Forward" />

My firefox version is Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20061201 Firefox/ (Ubuntu-feisty)

This also works for me, but "XF86Back" seems to be *the same* (toggles the same command, but only in FireFox) as [Alt Gr]-Key on German keyboards, even if xev shows nothing like this. Bug in FireFox? Therefor I have stick to the F19/F20 workaround.

--BDKMPSS June 04 2007

Yes, this hint should be dropped. This was bug in firefox, fixed long time ago:

It is fixed in firefox above 3.5 (and nobody should use older versions, really).

Fake ACPI events?

Not all keys generate ACPI events. Maybe it is feasible to have the ibm-acpi module check the CMOS (instead of having tpb checking /dev/nvram) and generate fake ACPI events for those keys. Even if it is feasible, that is probably way to hacky for a kernel module ... Still, it would be nice to only have to use scripts triggered by ACPI events and not both scripts for ACPI events and scripts for tpb.

I think something like this is possible with ibm-acpi 0.10 already. It provides a proc file from which you can derive a table of CMOS states. You'd only have to figure the who is who of CMOS bits and write a daemon (or daemon like shell script) checking them regularly. This should be about what you suggest since tpb does the same thing with the bios ram. Of course generating ACPI events can not be done like that (or can it?), but you could trigger the ACPI action scripts directly then.

Wyrfel 01:02, 14 Mar 2005 (CET)

It may be possible (I have a 770x, so don't have the special keys) to add the keys as real ACPI events, by altering the DSDT. I've done this to enable ACPI events for Fn-(every labelled F key),Home,End,PgUp,PgDn on mine, and they aren't labelled with anything physically (no thinklight and physical brightness control). The Embedded Controller reports all events, including keys, by calling one of the _Qxx functions (you'll find a whole pile in the sourcecode for the DSDT). If you then insert a fucntion in the same scope as the others like:-

Method (_Q12, 0, NotSerialized) { \_SB.HKEY.MHKQ (0x1003) } //Fn-F3

when executed, ibm-acpi will then report an acpi event numbered 0x0001003. You should find some functions, e.g. _Q1B For Fn-F12 identical to this.

I found some IBM DSDT's had functions that made MKHQ calls for EC functions _Q63, _Q64, _Q4E, _Q4F, but did nothing on mine---maybe these are a good starting point. Add a whole pile, and see if you get lucky! (At your own risk, of course... :/ But it should be pretty safe).

Yes, the above sounds pretty identical to tpb, except with /proc/ibm/ecdump instead of /dev/nvram. The above works very nicely, however there's luck involved in finding the right number, even if it exists!


Fn+F6 does not seem to generate an event on t41p even if the mask is set to 0xffff and experimental=1 is passed to ibm_acpi tf

Bind Fn to super or hyper


Is it possible to bind Fn via Xmodmap to a key modifier such as hyper or super? Thanks Oub 13:14, 6 February 2006 (CET):

I doubt it. The event for the Fn key is generated at release (as opposed to holding it where it serves it's usual special function). Hence you can't use it as a modifier. Wyrfel 22:52, 6 February 2006 (CET)

I have added a paragraph how to get around the issue that Fn is not working with other key combos than the ones intended. Mebbe that helps you. --Low 12:09, 11 December 2008 (CET)

Bind Fn 12 say to F34

Thanks Wyrfel for your reply, in order to display my question better, I use a new header: can I bind all the Fn Fx to hay F34 and the like? Oub 21:33, 10 February 2006 (CET):

You can do this with all key combinations that support xmodmap (see the table). That means you can't do it with Fn}F12, because that combination doesn't generate a key event at all (it only generates an APM/ACPI event. Hence there is nothing vor xmodmap to remap.

But what is your wider focus goal? I'm sure that what you want to do can be realized, anyway: You can write an ACPI script and event file for FnF12 and have the script start some tool that sends a F34 key to the X server. I'm sure this is possible.

Wyrfel 00:03, 11 February 2006 (CET)


Fn does not accept other key combos than the acpi ones (e.g. Fn+F4). However you can assign it to be CapsLock, and use the CapsLock then for the purpose of having key combos. See the paragraph about enabling fast NumPadding:

How to get special keys to work#NumPad (KeyPad) keys access by a key combination

--Low 12:18, 11 December 2008 (CET)

Can't bind Fn 12


I am using a R51 and I have compiled ibm-acpi monolithic in the kernel (not as module, maybe this is a mistake?). Anyway, I am using suspend2, which I compiled in the kernel as well. Now I have bound to hibernate first to Fn 4, with the following script

event=button[ /]sleep  

This works fine. Now I want to do the same for Fn12, so following the key table I did:

event=button[/] ibm/hotkey HKEY 00000080 0000100c  

But that does not work. What is the problem? I tried even

echo enable,0xffff >/proc/acpi/ibm/hotkey 

without success. Can anybody help me? Oub 16:27, 4 March 2006 (CET):

The proper event line is

event=ibm/hotkey HKEY 00000080 0000100c


Also, make sure that you are not using [thinkpad-acpi]. If event=button[ /]sleep works for FnF4, that indicates that you do. It might block the ibm-acpi driver. Check your kernel config and disable any thinkpad acpi driver except ibm-acpi.

Wyrfel 21:58, 4 March 2006 (CET)

It is odd, I am pretty sure, that I do not use [thinkpad-acpi], but [ibm-acpi], although event=button[ /]sleep works for FnF4, in any case I found out that
event=(button/power|ibm/hotkey HKEY 00000080 0000100c)
Works! What do you think of adding a subsection to the How to get special keys to work page, with some examples, like the following:
from /etc/acpi/events/battery:
event=(button/power|ibm/hotkey HKEY 00000080 0000100c)  
from /etc/acpi/events/lid
from /etc/acpi/events/sleepbtn
event=(button/sleep|ibm/hotkey HKEY 00000080 00001004)
(Also event=button/sleep works for me)
and then restart acpi:
/etc/init.d/acpid restart
Oub 13:22, 5 March 2006 (CET):

What you do with

event=(button/power|ibm/hotkey HKEY 00000080 0000100c)  

is to make a logical nonexclusive OR between



event=ibm/hotkey HKEY 00000080 0000100c

. If the first works, the whole thing works. So that's pretty logical.

Please, do a # dmesg | grep thinkpad-acpi and do a # dmesg | grep ibm-acpi. What is the output in either case?

I see no sense in putting examples to the page that only confuse people because they are not correct. ibm-acpi generates the events listed in the table and nothing else. If you get something like button/sleep it's not ibm-acpi generating it. You are running Debian, right? Let's hope they didn't patch the driver to generate different events.

Also, you can always do # tail -f /var/log/acpid to have a life view of the generated events.

I am pretty sure that you are using thinkpad-acpi or - if not so - that something else must interfere.

Wyrfel 04:49, 6 March 2006 (CET)

Ok I admit everything is very odd. For the start, I seem to use
ibm-acpi. As I said I am Debian, but I compiled my own kernel :(2.6.10)(but not as a module, maybe this was a bad idee??) and I used :the ibm-acpi driver which comes shipped with that kernel. I did not :download the driver from the official :site. Here is the output of
dmesg | grep acpi
Kernel command line: ro  root=/dev/hda6 acpi_sleep=s3_bios
tbxface-0118 [02] acpi_load_tables      : ACPI Tables successfully acquired
evxfevnt-0094 [03] acpi_enable           : Transition to ACPI mode successful
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [df6ddaa8]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c1464768]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c1467328]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c146bba8]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c146b628]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c146b3e8]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c146b268]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c146dde8]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c1470d68]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c1470568]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c14719a8]
ibm_acpi: IBM ThinkPad ACPI Extras v0.8
acpi_bus-0081 [08] acpi_bus_get_device   : Error getting context for object [c1467328]
ibm_acpi: dock device not present
I don't understand the errors but anyway. Now the odd thing is that indeed the following works
event=button[ /]sleep
Does not work. But from what you said, using the ibm_acpi neither of these strings should work? So I don't understand what is going on. Oub 20:28, 6 March 2006 (CET):

With any reasonably new kernel (2.6.16 in Thinkpad terms :-) ) and a good DSDT (say, like the one that comes inside the T43), you can get two classes of events: ACPI events (as in native ACPI events), and ibm-acpi hotkey events.

This has nothing to do with thinkpad-acpi.

Look under /proc/acpi/buttons. If you have sleep and maybe hibernate/suspend in there (I don't know how fn+f12 is called when properly supported through ACPI DSDT, the T43 doesn't support it like that), then your Thinkpad can, and will generate proper ACPI events without the help of ibm-acpi. This is valid for a complete ACPI config of kernel 2.6.16 with all modules loaded.

And it will generate regular ibm-acpi hotkey events if you enable the feature and use the correct mask, which may or may not confuse the thinkpad (I am not sure the correct DSDT handlers the BIOS expect to run are called in this case).

-- hmh 2006-05-26 13:20 UTC

Turn on/off Wifi on Fn5


I hope this is the last question. I use a crude way to activate and deactivate my wificard: I remove and insert the relevant modules, with 2 simple scripts. Now the question is how can I bind Fn5 so, that it turns on and off the wificard? With my approach I need to fire up two scripts, and that I cannot bind to one button. Thanks Oub 17:57, 5 March 2006 (CET):

Try a # cat /proc/acpi/ibm/bluetooth. Maybe it returns the state. If not, the other way would be to check if the USB bluetooth controller device is listed in /proc/bus/usb somewhere. It shouldn't be there if bluetooth is switched off and should be there if it is on.

Wyrfel 04:49, 6 March 2006 (CET)

Split page?

This page is getting too long. Maybe we should split it. I'd suggest moving the "Example applications" to a seperate page.

Paul Bolle 22:46, 3 April 2006 (CEST)

DIY Firefox 1.5 xpi

Here's how I maneged a Firefox 1.5 compatible plugin (source: google). Note that the wiki eats some of the xml tags (so look at the source too)

$ ls -1R tp41.xpi


$ cat tp41.xpi/chrome.manifest
content     tp41keys    chrome/content/
overlay chrome://browser/content/browser.xul chrome://tp41keys/content/tp41keysOverlay.xul
$ cat tp41.xpi/install.rdf
<?xml version="1.0"?>

<RDF xmlns=""

  <Description about="urn:mozilla:install-manifest">


    <em:name>IBM ThinkPad 41 Keys</em:name>
    <em:description>Two Browser Navigation Keys</em:description>
    <em:creator>Paul Bolle</em:creator>
$ cat tp41.xpi/chrome/content/tp41keysOverlay.xul
<?xml version='1.0'?>
<!DOCTYPE overlay>

<overlay id='tp41keysOverlay'
    <keyset id='mainKeyset'>
        <key id='tp41BackKey' keycode='VK_F21' command='Browser:Back' />
        <key id='tp41ForwardKey' keycode='VK_F22' command='Browser:Forward' />

$ cat .mozilla/firefox/*.default/extensions/tp41keys\ 

ibm-acpi hint

I would like to add a hint under ibm-acpi to enable all hotkeys at boot, but I can not seem to get the HINT template to work:

{{HINT|To enable all hotkeys on boot in debian, create the file /etc/modprobe.d/ibm_acpi containing 'options ibm_acpi hotkey=enable,0xffff'}}

It outputs:


Any ideas on how to get this to work? Also, does it even belong in the page?

--Paul Strefling 23:22, 10 August 2006 (CEST)

If you use ibm-apci as a module and have /proc filesystem enabled, you can tune it by adding to /etc/modules.d/ibm_acpi:

    post-install ibm-acpi /bin/echo enable,0x00d0 > /proc/acpi/ibm/hotkey

I added it after alias ibm-acpi ibm_acpi. I'm not sure - if the order make sence. Params can be differ - it is an example.

Also works fine with # modprobe (don't forget to run # modules-update after editing /etc/modules.d/*).

(tested on Gentoo with vanilla kernel).

Lock Screen with hotkey on models before T60

In case it's of interest, it's possible to simulate the "lock screen" (Fn+F2) function of T60s on prior models. I wrote a little HOWTO on the Gentoo forums explaining how to configure Fn+F3 to fire up xscreensaver instead of blanking the screen (though this could easily be changed to Fn+F2 instead). This was for my T42 but I presume it'd work on other models too. Perhaps it'd be worth mentioning in the Remarks column of the Fn+F2 row of the table at the top of the article? --Waveform 03:42, 2 January 2007 (CET)

Toggle touchpad with Fn-F8

I often want to switch off the touchpad, since I tend to produce spurious taps while typing, sending my cursor to random places on the screen. To toggle touchpad operation, I use this little script:

# toggle touchpad operation
# August 2, 2006
# (c) Michael Schmuker
if synclient -l | grep TouchpadOff | grep -q 0; then 
    synclient TouchpadOff=1;
    kdialog --passivepopup "Touchpad is OFF" 2;
    synclient TouchpadOff=0;
    kdialog --passivepopup "Touchpad is ON" 2;

This checks if the touchpad is on or off, and toggles its state accordingly. Note that it uses kdialog to display a notification on the desktop. This obviously works only with KDE, but there certainly is a similar mechanism for other desktop environments.

Now this script needs to be bound to the Fn-F8-key. On Suse 10.2, the ACPI-events produced by the thinkpad special keys are processed by powersaved. You need to edit the file /usr/lib/powersave/scripts/thinkpad_acpi_events. There, thinkpad-ACPI events are bound to their actions. Where it comes to Fn-F8, just change it to the following (supposed you put the above script to /usr/local/bin/toggleTouchpad and make it executable):

4104)   HOTKEY="Fn+F8" #toggle touchpad on/off

Save the file, and the next time you press Fn-F8 you will toggle your touchpad.

Unfortunately, the notification via kdialog is not working when toggling with Fn-F8. If anyone finds out how to solve this: Let us know!

Possible Solutions:

1. You can instead use syndaemon, which can turn off the touchpad for a brief period while you are typing.

2. All acpi events are run as root. Therefore, to enable the kdialog, you will need to incorporate a script to determine which user is running on DISPLAY :0.0; something like the following should work (put it in your acpi file)

if ps -e | grep -q -E '(enlightenment|kwin|dwm)'; then
       X_USER=`/usr/bin/who | /usr/bin/sed -n "s,^\(.*\):0 .*$,\1,p"`
       X_USER=${X_USER/ /};
       export DISPLAY=:0.0
if [ -n "$X_USER" ]; then su $X_USER -c "/usr/local/bin/toggleTouchpad";
else /usr/local/bin/toggleTouchpad;

--Ppurka 18:43, 14 September 2007 (UTC)

What about older machines?

On the 600X, Fn+PgUp and Fn+PgDn control speaker volume and Fn+Backspace toggles speaker mute. In addition, Fn+F2 is shows a battery icon and the manual states that it brings up a battery monitor. It hasn't worked since Windows 95. Fn+F11 shows a dripping tap and is meant to select a power mode. Fn+F8 has no icon but toggles screen expansion.

On the 750P, Fn+F5 and Fn+F6 control speaker volume, and I think Fn+F2 and Fn+F11 show the same icons as the 600X. However, that machine certainly doesn't have ACPI. Fn+F8 toggles screen inversion (black shows as white and vice-versa) on the monochrome models and Fn+F9 toggles brightness inversion (normal characters become bright and bright characters become normal). Those two only affect the internal LCD and not the signal on the VGA connector.

--Whizkid 19:32, 27 November 2007 (UTC)

Please add that information to the Default meanings of special keys page, including the description of the icons and functions. As for how to use these keys, it depends. How well does thinkpad-acpi work on the 600X and 750P? If it doesn't work at all, then you have to resort to tpb, which may have no idea how to access these keys in NVRAM :-(

--hmh 14:18, 30 November 2007 (UTC)

I've updated the descriptions of functions on that page for 750P, 560E and 600X. There are no descriptions of icons anywhere on that page. An example to start with would be nice. The 750 family doesn't have ACPI at all. --Whizkid 14:09, 25 December 2007 (UTC)

ThinkVantage button not recognized by xev under Hardy


I would like to set up the ThinkVantage button as XF86LaunchA, but I simply can't as it doesn't give any signal in xev. Any ideas how could I fix this?

Thanks, Nagyv 22:54, 3 July 2008 (CEST)

As the button is no "real keyboard button" it does not generate a keycode, but an acpi event (maybe thinkpad_acpi is needed for it to work) which you can set up to do what ever you want (well, not everything). see the article.

--BDKMPSS 23:45, 3 July 2008 (CEST)

Thank, this worked. I only had to add a new file under /etc/acpi/events. As there were many working examples, it was easy to write my own. Finally, I had to restart acpid.

thanks, Nagyv

Who is the boss? Your Thinkpad's special keys or you?

The x tools setxkbmap and xbindkeys along with the kde 3.5 control center keyboard shortcuts and application links in ~/.kde/Autostart are the tools that I use to do every keyboard thing I want with my

  • R61 7732-CTO
  • BIOS 7LETC4WW (2.24), EC 7KHT24WW-1.08
  • Intel(R) Core(TM)2 Duo CPU T5470 @ 1.60GHz, stepping 0d
  • 4G Mushkin RAM
  • 320G WDC WD3200BEKT
  • Linux version 2.6.30-4-amd64
  • kde 3.5.10
  • Debian Stable
  • Number of Packages: stable 1473, testing 473, unstable 199

You may also find xmodmap useful, I didn't.

check out:

man setxkbmap

man xbindkeys

man xbindkeys-config

anything else you need would be in /usr/share/doc/ on Debian

You must! learn to use Google effectively

An important command for getting this together was on the HotkeyResearch page:

xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'

It told me which fn-{key} had keycodes and what they were. I was surprised to find that some didn't have keycodes.

Here's the way to do it:

1) read the above references!! don't email me with questions that have answers in the text.

2) set your keyboard properly. I looked at /etc/X11/xkb/base.xml <name> tag values, then created in ~/.kde/Autostart with konqueror a "link to application" for the statement 'setxkbmap -model thinkpad60 -layout us'

3) use the above xev|etc. command to find the keycodes for the keys you need to map.

4) for fun you can look at the keycode to keysym correspondences that exist currently by executing xmodmap -pk at the command line

5) you may have to create an ~/.xmodmap with the keycode to keysym additions or modifications, I didn't

6) determine what functionality you want the key combinations to provide

7) use kde keyboard shortcuts to map key combinations (ex fn-F5) to your shortcut scheme. If it doesn't have something you want, like control of amarok with the multimedia keys you either need to create a menu item for the application and a command shortcut or you can use xbindkeys-config to do it. You can't do both.

8) I used xbindkeys-config for a few things but it became a little difficult to use so I created menu items. I later realized that xbindkeys-config and xev didn't see the same keys. I had to map fn-F4 with xbindkeys-config and fn-F12 with a command shortcut.

9) the amarok controller I used is remoot, just search for it, it isn't in Debian, but a Debian package is available

I will be writing sometime soon on suspension/hibernation. I use pm-suspend and pm-hibernate, which are in the pm-utils Debian package. If I can figure it out, you can too. Read the documentation.

Dare to be great! Kick butt!


Microphone Mute Key

I've filled a bug report (LP728310) for the missing microphone mute support in Ubuntu 10.10.

This bug report contains some info about how to get a bit of the functionality working.

--Dveeden 10:39, 3 March 2011 (CET)

Got R51's "Access IBM" key working in Openbox (key="XF86Launch1")

Noting it here because it isn't mentioned in the article. XF86LaunchA didn't work for me, but xev told me my Thinkpad R51's Access IBM key was XF86Launch1, and sure enough it worked.

I'm on Lubuntu (14.04) so my Openbox config is located at ~/.config/openbox/lubuntu-rc.xml. Here's what I added:

   <keybind key="XF86Launch1">
     <action name="Execute">
       <command>xmessage "You just pressed XF86Launch1"</command>

Quaternion (talk) 21:59, 26 January 2015 (UTC)