LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 11-23-2003, 03:16 AM   #1
grizzly
Member
 
Registered: Jun 2003
Distribution: Slackware 9.1, Solaris 9, and IPcop
Posts: 101

Rep: Reputation: 15
changing keyboard keys functions


When using vi esc is a very popular key, however it is out of the way, it tends to slow down my typing having to reach up there to hit it. Is there a way I can change this key to say this little key in the lower left with a flag on it that has no purpose?

I am running Slack 9, about to upgrade to 9.1 in mid-dec. I typically use gnome if that makes any difference.

Mike
 
Old 11-23-2003, 09:33 AM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
As far as I can tell, Vim doesn't recognize that key - I couldn't find any reference to it and trying to define it in xmodmap was pointless, as it's already defined. So I'm not sure how to manage the specific idea. As far as just getting keys to do different stuff, you could do something like adding

imap <C-Space> <Esc>

to your ~/.gvimrc (or whatever's appropriate) but conflict with default keybindings is always a possibility. I think that particular one is okay, though. Just an example, as that would just map ctrl-space to escape in insert mode.

I have that odd little key bound to all my fluxbox windowing operations and app launcher accelerators. It is a cool key to bind, as it's not already bound, usually.

-- Actually, I now realize this whole post is nonsense if you meant vi. I don't know anything about the actual vi. I tend to interpret references to 'vi' as 'vim' (even if Slack's 'vi' is 'elvis'). Sorry if I was totally off base.

Last edited by slakmagik; 11-23-2003 at 09:35 AM.
 
Old 01-10-2004, 10:05 PM   #3
grizzly
Member
 
Registered: Jun 2003
Distribution: Slackware 9.1, Solaris 9, and IPcop
Posts: 101

Original Poster
Rep: Reputation: 15
remapping esc key to win keys

digiot, I thank you for the reply above. I was in fact using elvis, however since that time I have changed it over vim.

I have finally got around to figuring this out, so I am writing how I did it on my system in case anyone is interested, or if there is a search for this subject the answer will be here.

The keys I want to remap are the two keys on the bottom of the keyboard that have the windows flag on them. On the left side it is between the ctrl and alt keys, on the right it is next to the alt key. In windows this key will pop up the start menu, I don't use windows, so I am finding another use for them.

Below is how I did it for my system. If you want to try this do so at your own risk, I could see it being really easy to whip out your keyboard doing some of this stuff, so make the backup files. My system is as follows:
Slackware 9.1
linux 2.4.22 kernel
X-Windows, using gnome 2.4
using default keymap (this is very important, you must edit the keymap you use).

First I discovered that the console, say under ctrl+alt+F2, uses a different keyboard map than the X system. To change the mapping for the console this was the process:

First I needed to know what the number of the keys were what I wanted to change. To do this I switch over to another console and did the command:
$> showkey
then when you type a key it will show you the numbers.
For my system the esc key is number 1 and the two windows keys were 125 and 126.
The showkey command does not work well under an Xterm. When I did it using an Xterm I had to kill the process, it won't shut itself down.

Then, I ran the loadkeys -d command to find out what was the default keymap for my system. This returned the following directory:
/usr/share/kbd/keymaps/i386/qwerty/defkeymap.map.gz

I cd'd into that directory and made a copy of the file, the second is a backup, I usually just
add .backup to the end of the file name, i.e., defkeymap.map.gz.backup.
Then I unzipped the file:
$>gunzip defkeymap.map.gz
which gave the unzipped file:
defkeymap.map

I opened up the file in vi and copied everything under number 1 and pasted it under the numbers 125 and 126. Here is the example of my file for these numbers:

keycode 1 = Escape Escape
alt keycode 1 = Meta_Escape

...

keycode 125 = Escape Escape
alt keycode 125 = Meta_Escape
keycode 126 = Escape Escape
alt keycode 126 = Meta_Escape

In the area that says 1= Meta_Escape, you do need to change the 1 to 125 and 126 like it is listed here.
Once that was done, I just saved the file, re-zipped it with
$>gzip defkeymap.map

Then I ran the loadkeys -d command again, and in the console, I then could use either one of the win keys as an escape.

The X-term has a little bit more involved. For this I started a X-term session, then ran the command :
$>xev

This pop's up a little window, and gives an enormous about information. I click in the window to make sure it was the window that was receiving the commands, then I would hit the keys I wanted to change, in this case the esc key, and the two windows keys. The output to this looked like:

KeyPress event, serial 25, synthetic NO, window 0x1e00001,
root 0x3a, subw 0x0, time 29429511, (175,175), root185,255),
state 0x10, keycode 9 (keysym 0xff1b , Escape), same_screen YES,
XLookupString gives 1 bytes: ""

This gives the keycode number I was looking for, and the keysym number. I needed to write down the keycode number of all three keys, and the keysym number of the esc key.

Then in my home directory, I create a file called .xmodmaprc and put in the following information.
keycode 115 = 0xff1b
keycode 116 = 0xff1b

That is the total contents of the file. The keycode's are the code's for both windows buttons, and the 0xff1b value is the keysym value obtained from the xev command.

I then saved this file, and set the execute permissions.
Then I ran xmodmap ./.xmodmoprc, and then the two windows keys worked as escape keys. I put the line:
xmodmap .xmodmaprc in my .bashrc file, so every time I log in it should run it.

The man page for xmodmap is really detailed, and would be great place to get questions answered.

*Note: I am not the best with terminology, If I have put something confusing in here let me know, I will happily change it.

Good Luck,

Mike
 
  


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
changing y and z keys back iXaarii Linux - General 5 06-25-2005 10:31 PM
Assigning functions to inactive keys... JoannesX Programming 9 05-03-2005 02:29 PM
changing objects parameters via getters inside functions in c++? markhod Programming 1 03-08-2005 06:30 AM
some keys are not functinal on keyboard chongluo Linux - Newbie 3 10-10-2004 06:38 AM
Assigning keyboard shortcuts to keyboard keys the who Linux - Hardware 3 02-20-2004 10:36 PM


All times are GMT -5. The time now is 12:46 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration