Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-23-2013, 06:41 PM   #1
LQ Newbie
Registered: Nov 2013
Posts: 3

Rep: Reputation: Disabled
complicated key remap (multiple keys at once)

I recently switched to linux from windows. Been thinking about it for years, but win8 pushed me over the edge. I'm now running mint/cinnamon (gtk+). So far I'm loving it! Only one thing I haven't been able to figure out so far:

On my laptop, the pgup/pgdn/home/end keys are done by Fn + arrow keys. Problem is, only one Fn key, and it's on the other side of the keyboard. Can't pgup/pgdn with only one hand.

In windows I used AutoHotKey to remap the "menu" key, which is very close to the arrow keys. If pressed in conjunction with one of the arrow keys, it was treated as a modifier key, like ctrl, alt, etc. And so I could create the following scripts to make menu+up act like pgup, etc. But if pressed by itself, when the key was released (key up event) it would still open the menu. Like this:

SC15D & Up::send {blind}{pgup}
SC15D & Down::send {blind}{pgdn}
SC15D & Left::send {blind}{home}
SC15D & Right::send {blind}{end}
SC15D UP::send {vk5Dsc15D}

This method would even allow additional modifiers: like if you pressed shift+menu+up, you would get a shift+pgup. Same with ctrl, alt, etc.

I've seen how to do simple remaps in linux, but that doesn't seem to work with anything but the standard ctrl, alt, shift, super modifier keys. Is this menu+arrow thing possible? Been searching for about a week now, no luck thus far. But oh boy, have I opened the menu a million times when I was trying to do home/end/pgup/pgdown! Thanks in advance.
Old 11-25-2013, 04:18 AM   #2
Senior Member
Registered: May 2010
Location: Planet Earth
Distribution: Debian
Posts: 1,030

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Under preferences open keyboard and then in the tab shortcuts you will see in the botton of the list "custom shortcuts" where you can set it your way. Now if you are already there trying to get it done but no go, then there is the xmodmap program that you run in the terminal, type man xmodmap in the terminal to open the manual.
Also you will need xev another program the runs in the terminal what it does is to capture the keys pressed and give back the codes for the keys, alot info is generated, in the line where you see something like this:
keycode 37 (keysym 0xffe3, Control_L)
is the code and hexa value for the key that you pressed. To know more about xev, type in the terminal man xev.
Yet another way to change it is in /usr/share/X11/xkb/symbols/pc where you can directly edit the keyboard, but would be wise to backup the file(s) before start.

You can find some more info about it here:

Old 12-02-2013, 07:11 AM   #3
LQ Newbie
Registered: Nov 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for the reply; I had already been looking at both of those, as well as autokey and xbindkeys.

Of those solutions, the most promising so far has been xbindkeys; but the problem seems to be that you can only map certain keys to a modifier. IF I could map the menu key to Mode_switch, then I'd be golden. But it won't work. I read somewhere that this is an xorg limitation, not just xmodmap.

However, I may have found a solution, writing a c program using XRecord to monitor key events.

My first try worked, but required me to unmap the menu key and arrow keys, and then use XTest to send either correct key event, depending on whether the menu key was down. But I don't like unmapping my arrow keys; if the program terminates I'm left with no arrows until I change the map or restart the program.

Possible better way: seems like I could just unmap the menu key (135) (actually remap it to like 255 or something). Then when my program sees a 135 keydown/up event, it sends a mode_switch keydown/up event. Hope it works...
Old 12-02-2013, 09:24 AM   #4
LQ Newbie
Registered: Nov 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled

I figured it out!! It was the key repeat that was preventing me from making the menu key a modifier, but there is a command to disable the repeat! Here's what I did:

xset -r 135
xmodmap -e "keycode 248 = Menu NoSymbol Menu"
xmodmap -e "keycode 135 = Mode_switch"
xmodmap -e "keycode 111 = Up NoSymbol Prior"
xmodmap -e "keycode 116 = Down NoSymbol Next"
xmodmap -e "keycode 113 = Left NoSymbol Home"
xmodmap -e "keycode 114 = Right NoSymbol End"

This changes the menu key to a mode_switch, and then overlays the arrow keys with the functionality I wanted.

Obviously this sacrifices the menu key functionality, but I found a program that can add that back in (it would activate on keyup, if no other key was pressed)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remap the function keys in Byobu javascriptninja Linux - Software 0 01-29-2012 02:50 PM
Key remap Silverdaz Fedora 0 06-23-2004 09:28 AM
Desperately need to remap keys in Gnome basemodel Linux - Software 2 03-30-2004 12:50 PM
Remap windows keys graffitici Linux - Hardware 1 01-09-2004 05:55 PM
How do I remap keys? LooseCanon Linux - Newbie 1 08-27-2003 06:08 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:41 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration