Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Keyboard remapping

27 views
Skip to first unread message

Daniel Dalton

unread,
Feb 28, 2013, 4:10:01 AM2/28/13
to
Hi,

I recently bought a new laptop.

Annoyingly the laptop function key is where you'd expect the control key
and the control key is one key in from the left.

Is it possible to make the fn key act as a control key inside of linux?
(I'd like to keep the functions of the fn key combinations if
possible).

Thanks,
Daniel


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/20130228090...@gwsc.vic.edu.au

Karl E. Jorgensen

unread,
Feb 28, 2013, 5:20:01 AM2/28/13
to
Hi


On Thu, 2013-02-28 at 09:09 +0000, Daniel Dalton wrote:
Hi, 

I recently bought a new laptop. 

Annoyingly the laptop function key is where you'd expect the control key
and the control key is one key in from the left. 

Is it possible to make the fn key act as a control key inside of linux?
(I'd like to keep the functions of the fn key combinations if
possible). 

Oh - that's really something you want to check before buying it !

Unfortunately, in my experience, the answer to your question is no.  The problem is that the Fn key does not send a keycode to the O/S like the Ctrl key does - it is handled entirely in the keyboard (firmware?) itself.

However, you can probably swap Caps Lock and Ctrl ... I've done that in the past when I have worn out the left Ctrl key...



Thanks, 
Daniel 



Daniel Dalton

unread,
Feb 28, 2013, 6:30:01 AM2/28/13
to
Hi,

On Thu, Feb 28, 2013 at 10:19:38AM +0000, Karl E. Jorgensen wrote:
> Annoyingly the laptop function key is where you'd expect the control key
> and the control key is one key in from the left.
>
> Is it possible to make the fn key act as a control key inside of linux?
> (I'd like to keep the functions of the fn key combinations if
> possible).
>
> Oh - that's really something you want to check before buying it !

Yes, though not usually something that springs to mind sigh.
(especially when buying online)

>
> Unfortunately, in my experience, the answer to your question is no.  The
> problem is that the Fn key does not send a keycode to the O/S like the
> Ctrl key does - it is handled entirely in the keyboard (firmware?) itself.

Hmm, I suppose I'll just get used to the layout eventually... :)

Thanks for your help.

Daniel


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/20130228112...@gwsc.vic.edu.au

Paul Seyfert

unread,
Feb 28, 2013, 6:50:02 AM2/28/13
to
Hi,
I only know of thinkpads having ctrl and fn swapped wrt. other vendors.
As explained these are hard/impossible to swap in software which is why
the bios of thinkpads offer the possibility to do this.

Therefore I recommend, looking around in the bios whether you find there
what you need.

Cheers,
Paul


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/512F37DD...@mathphys.fsk.uni-heidelberg.de

Harvey Kelly

unread,
Feb 28, 2013, 9:30:02 AM2/28/13
to
> On Thu, 2013-02-28 at 09:09 +0000, Daniel Dalton wrote:
> Is it possible to make the fn key act as a control key inside of linux?
> (I'd like to keep the functions of the fn key combinations if
> possible).

Are the keys recognised? Have you checked?

When you run this command:

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

Do you get any output?

I had a problem with the volume keys not working on my laptop
recently, but the above command gave the output of:

123 XF86AudioRaiseVolume
122 XF86AudioLowerVolume
121 XF86AudioMute

And using xbindkeys solved it (well, a Debian user told me how to
solve it using xbindkeys!):

http://lists.debian.org/debian-laptop/2013/02/msg00019.html

https://wiki.archlinux.org/index.php/Xbindkeys

H


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/CAErRyQi75Rs2HDfiVzkeekivSjw6Qtv5HyFnS+49yK2=Owr...@mail.gmail.com

Vincent Lefevre

unread,
Feb 28, 2013, 1:40:03 PM2/28/13
to
On 2013-02-28 14:21:30 +0000, Harvey Kelly wrote:
> > On Thu, 2013-02-28 at 09:09 +0000, Daniel Dalton wrote:
> > Is it possible to make the fn key act as a control key inside of linux?
> > (I'd like to keep the functions of the fn key combinations if
> > possible).
>
> Are the keys recognised? Have you checked?
>
> When you run this command:
>
> xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode \
> /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'

xev is generally of too high level for keys like Fn.

/lib/udev/keymap is probably better, though it is buggy.

And this is the right way to swap keys on a particular keyboard,
because if you use something like XKB, it will affect all the
attached keyboards.

--
Vincent Lefèvre <vin...@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/20130228183...@xvii.vinc17.org

Daniel Dalton

unread,
Feb 28, 2013, 8:10:01 PM2/28/13
to
On Thu, Feb 28, 2013 at 07:36:24PM +0100, Vincent Lefevre wrote:
> /lib/udev/keymap is probably better, though it is buggy.

Ok, so I haven't made any changes in there yet.

I've ran showkeys and found that the fn key has a key code.

However, when I do fn+j for example only the fn key code is noted.

While if I press the actual control key on the keyboard + j I see that
both key codes are recognised.

Does this ultimately mean that fn can't be used as a control key?

I was able to bind fn to switch virtual terminals, but not as a control
key it seemed to do nothing when I did fn+c to kill a process after
binding it as a control key.

In addition to this I've discovered that my keyboard does not have an
application key or a right windows key (the key you press to get a
context menu in a gui).... It is the equivalent of right clicking
basically. Since I'm blind and I can't use a mouse this key is kind of
important. How could I bind right alt to act as this key?

I thought Lenovo were known for good keyboards.... Sigh

Thanks,
Daniel


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/20130301010...@gwsc.vic.edu.au

Daniel Dalton

unread,
Feb 28, 2013, 8:20:01 PM2/28/13
to
On Thu, Feb 28, 2013 at 11:56:29AM +0100, Paul Seyfert wrote:
> I only know of thinkpads having ctrl and fn swapped wrt. other vendors.
> As explained these are hard/impossible to swap in software which is why
> the bios of thinkpads offer the possibility to do this.
>
> Therefore I recommend, looking around in the bios whether you find there
> what you need.

It looks like my only hope.

I shall have a look...

Thanks for the tip.

Best regards,
Daniel


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/20130301010...@gwsc.vic.edu.au

Vincent Lefevre

unread,
Feb 28, 2013, 9:40:01 PM2/28/13
to
On 2013-03-01 12:07:07 +1100, Daniel Dalton wrote:
> On Thu, Feb 28, 2013 at 07:36:24PM +0100, Vincent Lefevre wrote:
> > /lib/udev/keymap is probably better, though it is buggy.
>
> Ok, so I haven't made any changes in there yet.
>
> I've ran showkeys and found that the fn key has a key code.
>
> However, when I do fn+j for example only the fn key code is noted.

What if you start showkeys in scan code dump mode?

> While if I press the actual control key on the keyboard + j I see that
> both key codes are recognised.
>
> Does this ultimately mean that fn can't be used as a control key?

I'd say that you have to try.

> In addition to this I've discovered that my keyboard does not have an
> application key or a right windows key (the key you press to get a
> context menu in a gui).... It is the equivalent of right clicking
> basically. Since I'm blind and I can't use a mouse this key is kind of
> important. How could I bind right alt to act as this key?

If you want to do this only for this keyboard (not for some USB
keyboard that you would connect), you can use /lib/udev/keymap
to map the scancode of the key to the wanted keycode (I don't
have such a key, so I don't know).

--
Vincent Lefèvre <vin...@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/2013030102...@xvii.vinc17.org

Daniel Dalton

unread,
Feb 28, 2013, 10:50:02 PM2/28/13
to
On Fri, Mar 01, 2013 at 03:38:23AM +0100, Vincent Lefevre wrote:
> On 2013-03-01 12:07:07 +1100, Daniel Dalton wrote:
> > On Thu, Feb 28, 2013 at 07:36:24PM +0100, Vincent Lefevre wrote:
> > > /lib/udev/keymap is probably better, though it is buggy.
> >
> > Ok, so I haven't made any changes in there yet.
> >
> > I've ran showkeys and found that the fn key has a key code.
> >
> > However, when I do fn+j for example only the fn key code is noted.
>
> What if you start showkeys in scan code dump mode?

How to do this?

> > In addition to this I've discovered that my keyboard does not have an
> > application key or a right windows key (the key you press to get a
> > context menu in a gui).... It is the equivalent of right clicking
> > basically. Since I'm blind and I can't use a mouse this key is kind of
> > important. How could I bind right alt to act as this key?
>
> If you want to do this only for this keyboard (not for some USB
> keyboard that you would connect), you can use /lib/udev/keymap
> to map the scancode of the key to the wanted keycode (I don't
> have such a key, so I don't know).

How to do that though /lib/udev/keymap appears binary?

Is it possible to do this through xmodmap or siilar I only need it for X
(gnome).

Thanks.


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/20130301034...@gwsc.vic.edu.au

Daniel Dalton

unread,
Mar 1, 2013, 2:20:02 AM3/1/13
to
On Fri, Mar 01, 2013 at 12:09:53PM +1100, Daniel Dalton wrote:
> On Thu, Feb 28, 2013 at 11:56:29AM +0100, Paul Seyfert wrote:
> > I only know of thinkpads having ctrl and fn swapped wrt. other vendors.
> > As explained these are hard/impossible to swap in software which is why
> > the bios of thinkpads offer the possibility to do this.
> >
> > Therefore I recommend, looking around in the bios whether you find there
> > what you need.
>
> It looks like my only hope.

This was indeed in the BIOS, thank you so much!

I just need to figure out now how to remap my "menu" key to either right
alt, right control or win key I guess... Ideas?

Best regards,
Daniel


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/2013030107...@gwsc.vic.edu.au

Vincent Lefevre

unread,
Mar 1, 2013, 7:40:02 AM3/1/13
to
On 2013-03-01 14:49:09 +1100, Daniel Dalton wrote:
> On Fri, Mar 01, 2013 at 03:38:23AM +0100, Vincent Lefevre wrote:
> > On 2013-03-01 12:07:07 +1100, Daniel Dalton wrote:
> > > I've ran showkeys and found that the fn key has a key code.
> > >
> > > However, when I do fn+j for example only the fn key code is noted.
> >
> > What if you start showkeys in scan code dump mode?
>
> How to do this?

The showkey man page (I suppose you meant showkey, not showkeys) says:

-s --scancodes
Starts showkey in scan code dump mode.

I haven't tried though, as showkey doesn't seem to work under X11
(contrary to /lib/udev/keymap).

> > > In addition to this I've discovered that my keyboard does not have an
> > > application key or a right windows key (the key you press to get a
> > > context menu in a gui).... It is the equivalent of right clicking
> > > basically. Since I'm blind and I can't use a mouse this key is kind of
> > > important. How could I bind right alt to act as this key?
> >
> > If you want to do this only for this keyboard (not for some USB
> > keyboard that you would connect), you can use /lib/udev/keymap
> > to map the scancode of the key to the wanted keycode (I don't
> > have such a key, so I don't know).
>
> How to do that though /lib/udev/keymap appears binary?

The documentation is here: /usr/share/doc/udev/README.keymap.txt.gz

For instance, in my case, I had written a file
/etc/udev/keymaps/apple-aluminum containing:

0x70035 86 # Left to z: 102nd (providing backslash bar)
0x70064 grave # Left to 1: grave notsign
0x70068 insert # F13

for the remappings I needed. The first number is the scan code, the
second word is the key code or some associated symbol corresponding
to the KEY_* macros from "/usr/include/linux/input.h". Due to a bug
in the udev keymap utility, I had to use the key code 86 instead of
the symbol 102nd above (though I've now written a patch, see Debian
bug 654947).

To do the remapping (mainly for testing) of my USB keyboard, I did:

$ /lib/udev/findkeyboards
USB keyboard: input/event2
AT keyboard: input/event0
Unknown type: input/event18

to get the device name, here input/event2, then:

$ sudo /lib/udev/keymap input/event2 /etc/udev/keymaps/apple-aluminum
Remapped scancode 0x70035 to 0x56 (prior: 0x29)
Remapped scancode 0x70064 to 0x29 (prior: 0x56)
Remapped scancode 0x70068 to 0x6e (prior: 0xb7)

After testing, I could do that automatically with a udev rule
/etc/udev/rules.d/98-apple-keyboard.rules containing:

# Apple Aluminum USB keyboard
ACTION!="remove", SUBSYSTEMS=="usb", ENV{ID_VENDOR_ID}=="05ac", ENV{ID_MODEL_ID}=="0221", RUN+="keymap $name /etc/udev/keymaps/apple-aluminum"

Here's the documentation I used:
* http://reactivated.net/writing_udev_rules.html by Daniel Drake
* udev(7) man page
* /usr/share/doc/udev/README.keymap.txt.gz
* /lib/udev/rules.d/95-keymap.rules (examples)

> Is it possible to do this through xmodmap or siilar I only need it
> for X (gnome).

xmodmap is obsolete, now broken (due to XKB features), and no longer
supported. It shouldn't be used any longer. XKB (setxkbmap / xkbcomp
/ ...) is the right solution for X, but some keys may need something
more low level. And XKB settings are lost after suspend / resume,
which is rather annoying (Debian bug 633849).

--
Vincent Lef�vre <vin...@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/2013030112...@xvii.vinc17.org

Daniel Dalton

unread,
Mar 1, 2013, 11:00:01 PM3/1/13
to
> For instance, in my case, I had written a file
> /etc/udev/keymaps/apple-aluminum containing:
>
> 0x70035 86 # Left to z: 102nd (providing backslash bar)
> 0x70064 grave # Left to 1: grave notsign
> 0x70068 insert # F13
>
> for the remappings I needed. The first number is the scan code, the
> second word is the key code or some associated symbol corresponding
> to the KEY_* macros from "/usr/include/linux/input.h". Due to a bug
> in the udev keymap utility, I had to use the key code 86 instead of
> the symbol 102nd above (though I've now written a patch, see Debian
> bug 654947).

Thanks. This sounds fairly involved,however, it turns out shift+f10 will
do what I want.

Dispite it being annoying my keyboard seems to lack this key I think
I'll stick to shift +f10 for now until I get some time to invest a few
hours in doing this.

Thanks for all your help and such a comprehensive response.

Best regards,
Daniel


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/2013030203...@gwsc.vic.edu.au
0 new messages