0

I'm learning how to use Ubuntu right now, so far I'm enjoying it. There is this one thing I don't understand. I want to replace my Pg Up button with Alt+T. If I want to use T only I know I should use

xmodmap -e "keycode 87 = t"

but I have no idea how to add the ALT button, any help.

2

2 Answers 2

2

Discover how your system sees those keys, using the command xev and pressing the keys whose id you want to discover.After entering the xev just press page up and then press alt+t then you will get the following results. Then use the key code you got on pressing alt+t keys in the command at the end. that's all it will be done. I did this on my laptop and got the below results and so i gave it for reference only. You have to perform action to get your own result as these results vary with computer.

Pressing Up produces keycode 111, assigned to action Up:

KeyPress event, serial 34, synthetic NO, window 0x3a00001,
root 0xa5, subw 0x0, time 13739005, (165,-16), root(170,32),
state 0x0, keycode 111 (keysym 0xff52, Up), same_screen YES,
XLookupString gives 0 bytes: 
XmbLookupString gives 0 bytes: 
XFilterEvent returns: False

Pressing Pg Up key gives the following:

KeyPress event, serial 32, synthetic NO, window 0x2400001,
root 0xc3, subw 0x0, time 13714833, (61,151), root:(63,236),
state 0x10, keycode 112 (keysym 0xff55, Prior), same_screen YES,
XLookupString gives 0 bytes: 
XmbLookupString gives 0 bytes: 
XFilterEvent returns: False

Once you know the keycode of the keys you would like to use, and the name of the actions you want to perform, you can assign the desired actions to the chosen keys. The following four commands will produce the desired change, valid only for the present X session:

xmodmap -e "keycode 112 = Up"

To get these changes for every session, after issuing the commands above, create a file called .Xmodmap (or whatever), with the following command:

xmodmap -pke > .Xmodmap

Then, create a file called .xinitrc in your home directory, containing just the following line:

xmodmap .Xmodmap

Enjoy!

Refer to the site for any doubts: http://wiki.linuxquestions.org/wiki/...txkbmap_Method

3
  • The OP asked to replace Pg Up with Alt+T, not with Up. So, the answer will be nice if will show how can the sum of two keys to be replaced with only one. And the given link is broken. Oct 6, 2013 at 17:21
  • Why did you changed xmodmap -e "keycode 112 = Up" to xmodmap -e "keycode 112 = Prior"? This is by default. See the output of xmodmap -pke | grep Prior command. Oct 7, 2013 at 11:00
  • Sorry it was a mistake.There is no change in it. Oct 7, 2013 at 13:24
0

You can't assign a combination of keys using xmodmap to a keycode. So, you can't replace replace Pg Up with Alt+T. If you do something like:

xmodmap -e "keycode 112 = Alt_L+t"

you will get an error.

You can understand this and if you look at the output of the following command:

xmodmap -pke

But with some tricks, if you really want to replace Pg Up with Alt+T, you can do it. You will need xdotool to do this. To install it run the following command in terminal:

sudo apt-get install xdotool

Now, just for test, if you run the following command in terminal:

xdotool key Alt+t

you will see that this have the same behavior like when you press Alt+T. So, all you have to do now is to add Pg Up as a custum shortcut for this command. See here how you can create a custom keyboard shortcut: https://askubuntu.com/a/69161/147044.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .