LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 01-11-2012, 12:09 PM   #1
hashbang#!
Member
 
Registered: Aug 2009
Location: soon to be independent Scotland
Distribution: Debian
Posts: 120

Rep: Reputation: 17
remapping keys


I recently bought a mini keyboard and I'd like to remap some keys as there are half a dozen keys I don't need and the frequently used ones are half size.

In .Xmodmap, I have mapped Delete onto Pause:

Code:
keycode 127 = Delete
That works great except for one application: GnuCash interprets my Pause (now Delete) as Ctrl-Delete, which deletes a transaction, which is particularly annoying as there is no undo function.

Any ideas would be greatly appreciated.
 
Old 01-12-2012, 10:54 AM   #2
DavidMcCann
Senior Member
 
Registered: Jul 2006
Location: London
Distribution: CentOS, Salix
Posts: 4,512

Rep: Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407
What output do you get from your new pause key using xev?
 
Old 01-12-2012, 11:03 AM   #3
hashbang#!
Member
 
Registered: Aug 2009
Location: soon to be independent Scotland
Distribution: Debian
Posts: 120

Original Poster
Rep: Reputation: 17

KeyPress event, serial 31, synthetic NO, window 0x4800001,
root 0x102, subw 0x0, time 25755458, (456,75), root1326,534),
state 0x10, keycode 127 (keysym 0xffff, Delete), same_screen YES,
XKeysymToKeycode returns keycode: 119
XLookupString gives 1 bytes: (7f) ""
XmbLookupString gives 1 bytes: (7f) ""
XFilterEvent returns: False




Many thanks in advance.
 
Old 01-12-2012, 12:20 PM   #4
hashbang#!
Member
 
Registered: Aug 2009
Location: soon to be independent Scotland
Distribution: Debian
Posts: 120

Original Poster
Rep: Reputation: 17
Is xmodmap the best way to go?

I have done some other stuff via setxkbmap:

.xinitrc
:
Code:
# start X with NumLock on
/usr/bin/numlockx on
# set keyboard to GB
setxkbmap gb
# stop capslock from being a capslock
setxkbmap -option "ctrl:nocaps"
# changes capslock to being a dead key
setxkbmap -option compose:caps
 
Old 01-13-2012, 11:13 AM   #5
DavidMcCann
Senior Member
 
Registered: Jul 2006
Location: London
Distribution: CentOS, Salix
Posts: 4,512

Rep: Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407
The xev output looks OK, so it's all a bit strange. Is the new Delete working in programs other than Gnucash, like Writer?

One solution is the 'quick and dirty one': modify /usr/share/X11/xkb/keycodes/evdev. This will have
<DELE> = 119;
<PAUS> = 127;
Swap the numbers and you're done.
 
Old 01-13-2012, 01:56 PM   #6
hashbang#!
Member
 
Registered: Aug 2009
Location: soon to be independent Scotland
Distribution: Debian
Posts: 120

Original Poster
Rep: Reputation: 17
Thanks for your help, David.

All other applications take my Pause key as Delete. Just GnuCash treats it as Ctrl-Delete.

To be honest, it would seem the tidiest solution to handle all key mappings in he same way, i.e. with setxkbmap if possible. Apparently, you can place all options in ~/.Xkbmap.

Last edited by hashbang#!; 01-13-2012 at 02:28 PM.
 
Old 01-13-2012, 02:27 PM   #7
hashbang#!
Member
 
Registered: Aug 2009
Location: soon to be independent Scotland
Distribution: Debian
Posts: 120

Original Poster
Rep: Reputation: 17
I think the cause of the problem is explained here:
Quote:
Pressing the dedicated Pause key on 101-key keyboards sends the same scancodes as pressing Ctrl, then NumLock
If I map Delete onto the ScrollLock key (just for testing), then GnuCash behaves as it should.

Other applications (terminals, editors, etc just pick up Delete. I just tested gedit, which distinguishes between Delete and Ctrl-Delete: it interprets my Pause key as Delete, not Ctrl-Delete.

Last edited by hashbang#!; 01-13-2012 at 02:28 PM.
 
Old 01-17-2012, 08:49 AM   #8
hashbang#!
Member
 
Registered: Aug 2009
Location: soon to be independent Scotland
Distribution: Debian
Posts: 120

Original Poster
Rep: Reputation: 17
This is not a GnuCash problem. In fact, I can reproduce this with other GTK applications:

In GnuCash, I had assigned the keyboard shortcut Ctrl-Delete to the menu item "Delete Transaction".

If I assign Ctrl-Delete to a function in ClawsMail, hitting my Pause key (onto which I mapped Delete) gets picked up as Ctrl-Delete.

This only happens with the Pause key. If I map Delete onto ScrollLock, I don't have the problem.



I am convinced the problem is caused by a Ctrl scancode being sent whenever Pause is hit.

If that is the case, how can I prevent Ctrl being sent?

Last edited by hashbang#!; 01-17-2012 at 08:50 AM.
 
Old 01-17-2012, 10:29 AM   #9
DavidMcCann
Senior Member
 
Registered: Jul 2006
Location: London
Distribution: CentOS, Salix
Posts: 4,512

Rep: Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407
I think you had the answer in #7: the mini keyboard is sending non-standard signals. If that's the case, it's built into the circuit board and there's nothing to be done. There was a similar case in another post, where function keys in a laptop worked directly on the hardware and only sent a scan-code when Fn has held down.
 
Old 01-17-2012, 03:36 PM   #10
hashbang#!
Member
 
Registered: Aug 2009
Location: soon to be independent Scotland
Distribution: Debian
Posts: 120

Original Poster
Rep: Reputation: 17
David, I am not sure I understand how you come to the conclusion that my mini keyboard is sending non-standard signals?

In this article someone describes what I would like to do for Winblows. I don't need the NumLock key either.

You probably understand more of this article than I do.
 
Old 01-18-2012, 11:20 AM   #11
DavidMcCann
Senior Member
 
Registered: Jul 2006
Location: London
Distribution: CentOS, Salix
Posts: 4,512

Rep: Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407
You said it yourself: you're getting a Ctrl along with the Pause. The keyboard in the article was giving 6 bytes for Pause, but a normal desktop keyboard only gives 2 bytes per key (even the big terminal keyboards with 24 function keys). As I said, there's nothing you can do about the codes from the keyboard, as they're generated by the circuitry; all you can do is alter the way the computer responds to them.
 
Old 01-30-2012, 07:13 PM   #12
hashbang#!
Member
 
Registered: Aug 2009
Location: soon to be independent Scotland
Distribution: Debian
Posts: 120

Original Poster
Rep: Reputation: 17
Why do some applications pick my remapped Pause key up as Delete (as intended) and others as Ctrl-Delete?

In GnuCash, I had defined Ctrl-Delete as a custom shortcut for "Delete Transaction". Hitting my remapped Pause key is interpreted as Ctrl-Delete and hence deletes a transaction.

If I define Ctrl-Delete as a shortcut for "Reply" in Claws-Mail, I get the same effect as in GnuCash: Pause brings up the "Reply" dialog.


However, gedit and medit have Ctrl-Delete defined as a built-in short-cut for deleting a word. Delete just deletes one character. When I hit Pause, it is taken as Delete and only deletes one letter.

I don't know another application that uses Ctrl-Delete as a shortcut for anything. But is it possible that custom accelerators handle my remapped key differently?

Quote:
Originally Posted by DavidMcCann View Post
all you can do is alter the way the computer responds to them.
How?
 
Old 02-02-2012, 05:21 PM   #13
hashbang#!
Member
 
Registered: Aug 2009
Location: soon to be independent Scotland
Distribution: Debian
Posts: 120

Original Poster
Rep: Reputation: 17
removed content

Last edited by hashbang#!; 02-06-2012 at 06:20 AM. Reason: that was nonsense (cleared post because I don't seem to be able to delete it)
 
  


Reply


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
Two questions about Vimperator (remapping of keys, jumping to text-input fields) TobiSGD Linux - Software 2 08-15-2011 06:46 PM
Changing the keyboard keys (that is, remapping them). stf92 Linux - General 7 06-10-2010 01:02 PM
Remapping shift&ctrl keys kills key repetition nitro2k01 Linux - Desktop 2 02-13-2010 12:56 PM
Remapping keys using xmodmap - "home" key leeko Linux - Newbie 0 06-28-2008 01:31 PM
Remapping keys - is it possible? LooseCanon Linux - General 2 09-03-2003 10:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:53 PM.

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