You are not logged in.

#1 2010-06-27 17:48:23

rent0n
Member
From: Italy
Registered: 2009-10-29
Posts: 457
Website

[Solved] Map Caps_Lock to Esc

Hi,
Since Caps_Lock is rather useless, I decided to map it to Esc, so that I can use vim and related apps more productively.
After searching around a bit I came across this solution:

1. create ~/.xmodmap:

remove Lock = Caps_Lock
keysym Caps_Lock = Escape

2. run at login:

xmodmap .xmodmap

The point is that now my Caps_Lock key works both as Escape *AND* Caps_Lock (also the led on the keyboard goes on and off).
xev recognizes it just as Escape but I can clearly see that it works as Esc and Caps_Lock in many apps.

Am I doing something wrong? How can I solve this issue?
Thanks!

Last edited by rent0n (2010-06-27 20:23:00)


rent0n@deviantART | rent0n@bitbucket | rent0n@identi.ca | LRU #337812
aspire: Acer Aspire 5920 Arch Linux x86_64 | beetle: Gericom Beetle G733 Arch Linux i686

Offline

#2 2010-06-27 17:58:19

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: [Solved] Map Caps_Lock to Esc

I could be totally off here, but since evdev detects the keyboard automatically, I am assuming that you might also have to disable the CAPS_LOCK key in your 10-evdev.conf file. So that it will only use your custom setting.

Or you could just not use the keyboard catchall in evdev and have your keyboard manually set up thru a custom file or in xorg.conf


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2010-06-27 19:04:46

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [Solved] Map Caps_Lock to Esc

These two lines in my ~/.xinitrc work for me  to make caps lock into the ESC key. No other files or commands needed.

xmodmap -e 'clear Lock' #ensures you're not stuck in CAPS on mode
xmodmap -e 'keycode 0x42=Escape' #remaps the keyboard so CAPS LOCK=ESC

Scott

Offline

#4 2010-06-27 19:46:45

rent0n
Member
From: Italy
Registered: 2009-10-29
Posts: 457
Website

Re: [Solved] Map Caps_Lock to Esc

I discovered this is a known xmodmap bug. Just search google for 'xmodmap .xinitrc'.

I solved adding:

setxkbmap -option caps:escape &

either to .xinitrc or to .config/openbox/autostart.sh.

Cheers,


rent0n@deviantART | rent0n@bitbucket | rent0n@identi.ca | LRU #337812
aspire: Acer Aspire 5920 Arch Linux x86_64 | beetle: Gericom Beetle G733 Arch Linux i686

Offline

#5 2010-06-27 20:07:08

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: [Solved] Map Caps_Lock to Esc

rent0n wrote:

The point is that now my Caps_Lock key works both as Escape *AND* Caps_Lock (also the led on the keyboard goes on and off)

This might be caused by the fact that you need to redirect both keys. I do use this one for quite some time to toggle between the mappings:

! Toggle caps lock and escape key arrangements
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock

Additionally I defined two setups to switch to a given mode:

! Swap caps lock and escape
remove lock =  0x42
keycode 0x9 = Caps_Lock
keycode 0x42 = Escape
add lock = Caps_Lock
! Original caps lock and escape
remove lock =  0x42
keycode 0x9 = Escape
keycode 0x42 = Caps_Lock
add lock = Caps_Lock

To know or not to know ...
... the questions remain forever.

Offline

#6 2010-06-27 20:22:20

rent0n
Member
From: Italy
Registered: 2009-10-29
Posts: 457
Website

Re: [Solved] Map Caps_Lock to Esc

@bernarcher: I didn't want to swap Caps_Lock with Esc but just to map Caps_Lock to Esc (and still have Esc working as Esc)
setxkbmap -option caps:escape does exactly what I want. smile


rent0n@deviantART | rent0n@bitbucket | rent0n@identi.ca | LRU #337812
aspire: Acer Aspire 5920 Arch Linux x86_64 | beetle: Gericom Beetle G733 Arch Linux i686

Offline

#7 2010-06-27 21:13:29

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: [Solved] Map Caps_Lock to Esc

Just for public info, this will swap them:

setxkbmap -option caps:swapescape

I've read here that some users end up with major problems with setxkbmap.

Offline

#8 2010-06-27 21:55:16

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: [Solved] Map Caps_Lock to Esc

Sligthly OT:
Trying to brush up my knowledge, I had a hard time to find the setxkbmap -options settings again. So for anyone interested, they are listed here:
/usr/share/X11/xkb/rules/xorg.lst

There is a setxkbmap article missing in the wiki. (If I only had the time...)


To know or not to know ...
... the questions remain forever.

Offline

#9 2010-06-28 02:20:27

saline
Member
Registered: 2010-02-20
Posts: 86

Re: [Solved] Map Caps_Lock to Esc

Any idea how to do this outside of X, as well (short of a new keymap)?

Offline

#10 2010-06-28 09:21:21

rent0n
Member
From: Italy
Registered: 2009-10-29
Posts: 457
Website

Re: [Solved] Map Caps_Lock to Esc

skottish wrote:

Just for public info, this will swap them:

setxkbmap -option caps:swapescape

I've read here that some users end up with major problems with setxkbmap.

Could you be more specific please? No problems here (for now).
Thanks


rent0n@deviantART | rent0n@bitbucket | rent0n@identi.ca | LRU #337812
aspire: Acer Aspire 5920 Arch Linux x86_64 | beetle: Gericom Beetle G733 Arch Linux i686

Offline

Board footer

Powered by FluxBB