LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   How to change key mapping in Ubuntu 9.10 (https://www.linuxquestions.org/questions/ubuntu-63/how-to-change-key-mapping-in-ubuntu-9-10-a-782835/)

taylorkh 01-17-2010 05:58 PM

How to change key mapping in Ubuntu 9.10
 
I have found that the <Enter> key on the numeric keypad does not act the same as the <Enter> key on the main keyboard. Confirming a file copy in Gnome Commander for example. Using xev I found the following
Quote:

Main <Enter>
------------
KeyPress event, serial 36, synthetic NO, window 0x5600002,
root 0x25d, subw 0x5600003, time 44244330, (50,55), root:(799,113),
state 0x10, keycode 36 (keysym 0xff0d, Return), same_screen YES,
" XLookupString gives 1 bytes: (0d) "
" XmbLookupString gives 1 bytes: (0d) "
XFilterEvent returns: False

Keypad <Enter>
--------------
KeyPress event, serial 36, synthetic NO, window 0x5600002,
root 0x25d, subw 0x5600003, time 44245090, (50,55), root:(799,113),
state 0x10, keycode 104 (keysym 0xff8d, KP_Enter), same_screen YES,
" XLookupString gives 1 bytes: (0d) "
" XmbLookupString gives 1 bytes: (0d) "
XFilterEvent returns: False
and using xmodmap -pke
Quote:

keycode 36 = Return NoSymbol Return NoSymbol Return
keycode 104 = KP_Enter NoSymbol KP_Enter NoSymbol KP_Enter
So based on some research it seems I should be able to edit my ~/.Xmodmap to assign the same key (Return) to keycode 104 - the keypad <Enter> key.

Except - I have no .Xmodmap. Am I supposed to? Did it move in Ubuntu 9.10? Do I have to create it? or does Ubuntu 9.10 use a "better" method of handling key mappings?

TIA,

Ken

DavidMcCann 01-19-2010 06:53 PM

What's your problem? The keypad always gives KP_Enter instead of Return, but both eventually generate code 0A.

taylorkh 01-19-2010 09:06 PM

Hi DavidMcCann,

The problem is that the keypad <Enter> does not activate the default button in dialogs. For example if I select a file in one Panel of Gnome Commander and press F5 to copy it to the location in the other panel a copy confirmation dialog comes up. The OK button is highlighted and is the default action. The main keyboard <Enter> will actuate the OK button. The keypad <Enter> will not.

Ken

DavidMcCann 01-22-2010 06:30 PM

That's weird! It works fine with Fedora. What does xev return for the keys? Mind you, my xev is odd here: it identifies them as CR instead of LF.

You could try using xmodmap to reconfigure the key (see the man page).

taylorkh 01-22-2010 07:39 PM

DavidMcCann,

The xev output is shown in the original post. I am not an expert in evaluating the data but is seems that the two keys are different. I will look into xmodmap.

Thanks,

Ken

taylorkh 01-22-2010 08:09 PM

Many thanks DavidMcCann!!!

I delved into xmodmap and found a few things:

If Ubuntu has a .Xmodmap file it is well hidden - I had started down this road once before but could not find any such file ANYWHERE on the system.

So, as there is supposed to be one in $HOME/ and the format is supposed to match the output of xmodmap -pke I simply redirected the output of the command to create my own .Xmodmap.

I opened my new .Xmodmap file in gedit. Then I looked up the Enter key, keycode 36 and copied the data for that key "Return NoSymbol Return NoSymbol Return" and replaced the data for the keypad return key keycode 104 with the same string. I restarted the PC (guess I could have logged out and back in) anyhow the custom keymappings loaded. I confirmed them in xev and found that Gnome Commander now honors the keypad enter key :D

Now if only I could get the Gnome "file selector" dialog to respect my "single click performs the action" preference. However, that seems to be related to a bug (or philosophical disagreement) which dates back about 140 years :(

Regards,

Ken

DavidMcCann 01-23-2010 11:59 AM

Quote:

Originally Posted by taylorkh (Post 3837128)
Now if only I could get the Gnome "file selector" dialog to respect my "single click performs the action" preference. However, that seems to be related to a bug (or philosophical disagreement) which dates back about 140 years :(

If you mean in the Nautilus file browser, you can alter this with Edit Preferences - Behaviour. In general, you can have a "simulated secondary click", where a slow release counts as a double click: see System - Preferences - Hardware - Mouse - Accessibility.

taylorkh 01-23-2010 08:21 PM

Hello again DavidMcCann,

The Nautilus file browser I have under control. Single click does the deed. Same for Gnome Commander. It is the dialog following Open; File (common to most applications) which does not work. I may try the mouse options although I will have to think what that might do in other situations. Which reminds me of a story...

I was working for a fortune 250 company converting data from a number of in-house applications to an off the shelf work management/supply chain suite of programs. We had a programmer on the team (a little weird - his belief was that if aquarium antibiotics worked for fish they would work for any other animal - even his family and himself) - anyhow the Lovebug worm was making its way around and this dude received a copy of it from some source. He saved it to his PC and right clicked on it with the intention of opening it in Notepad to have a look at the code. Anyhow he managed to trigger it. His PC was known to be a little flaky and often would seemingly substitute a double click for a single click on occasion or a double click for two single clicks a long time apart. Some weeks later, after Mr. Aquarium Antibiotics was fired for threatening another staff member, the PC presented a note on screen from Intel stating that the processor had exceeded its allowed error count and should be replaced under warranty. We did that and it never confused a click vs. a double click again.

Ken

oshunluvr 01-25-2010 03:55 PM

My answer to this issue was to create my xmodmap file in /etc/X11/ because I wanted all users to have the edited keys then edit /etc/X11/Xsession and add this line...

Quote:

# $Id: Xsession 967 2005-12-27 07:20:55Z dnusinow $

set -e

[ -f /etc/X11/Xmodmap ] && xmodmap /etc/X11/Xmodmap <----ADD THIS LINE HERE

PROGNAME=Xsession
If you wanted different xmodmaps for each user, change the file location to ~/Xmodmap or whatever you want

taylorkh 01-25-2010 04:02 PM

That is a great idea oshunluvr. However, as the only users of this machine are me, myself and I... My home directory seemed to be the right place.

Ken

oshunluvr 01-25-2010 04:06 PM

Then I suggest using ~/.xmodmap so the file is usually hidden from view.
Quote:

[ -f ~/.xmodmap ] && xmodmap ~/.xmodmap
The "-f" part in boxes checks to see if the file exists before loading so if you add another user, it won't try and load xmodmap


All times are GMT -5. The time now is 07:00 AM.