You are not logged in.

#1 2012-10-27 02:03:08

stewSquared
Member
Registered: 2011-07-05
Posts: 16

Holding the escape key

To be honest, what I'd really like to be able to do is be able to hold the CAPS key instead of push the ESC key every time I want to, say, move back a word (i.e. CAPS+bbbb should behave as ESC+b, ESC+b, ESC+b, ESC+b).

My solution so far is to use setxkbmap -option caps:escape (which I found by running "grep -r escape" in /usr/shar/X11/xkb/). This works great, as CAPS now behaves as ESC, but it's not exactly ESC that I want.

Thanks

Offline

#2 2012-10-27 02:06:06

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Holding the escape key

??

I assume you are talking about in vim?

Why not map the caps lock to shift, and map B to what you want it to do in vim?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2012-10-27 02:11:03

stewSquared
Member
Registered: 2011-07-05
Posts: 16

Re: Holding the escape key

I don't use vim, actually, but emacs. Basically, I want caps lock (sorry I should have typed it out) to behave as an extra meta key (I never use caps lock for anything else). And it does do that, but I want to be able to hold it down and have continue to behave as a meta key. As it is now, holding caps lock, then pushing 'b' twice moves me back one word, then prints 'b'

Offline

#4 2012-10-27 02:17:02

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Holding the escape key

It works as you described for me, if I have understood you correctly.

I have remapped CapsLock to Escape and, in a shell, if I hold down CapsLock and then hit b repeatedly the cursor skips back a word for every press of the b.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2012-10-27 02:25:19

stewSquared
Member
Registered: 2011-07-05
Posts: 16

Re: Holding the escape key

jasonwryan wrote:

It works as you described for me, if I have understood you correctly.

I have remapped CapsLock to Escape and, in a shell, if I hold down CapsLock and then hit b repeatedly the cursor skips back a word for every press of the b.

Wait, really? And you ran the same command the same command?

If I were to type the words "These are four words" and then hold CapsLock and push b, the result is still something like "These are four bbbbbbwords"

I thought, for a moment, that it might just be my shell (I'm using xterm), but I see the same behavior for any X program that I run.

Offline

#6 2012-10-27 02:47:16

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Holding the escape key

stewSquared wrote:
jasonwryan wrote:

It works as you described for me, if I have understood you correctly.

I have remapped CapsLock to Escape and, in a shell, if I hold down CapsLock and then hit b repeatedly the cursor skips back a word for every press of the b.

Wait, really? And you ran the same command the same command?

Yes: holding CapsLock and hitting b four times takes me back to the start of the
line…

I'm using urxvt{c,d}, bash and vi-mode.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2012-10-27 03:10:27

stewSquared
Member
Registered: 2011-07-05
Posts: 16

Re: Holding the escape key

jasonwryan wrote:
stewSquared wrote:
jasonwryan wrote:

It works as you described for me, if I have understood you correctly.

I have remapped CapsLock to Escape and, in a shell, if I hold down CapsLock and then hit b repeatedly the cursor skips back a word for every press of the b.

Wait, really? And you ran the same command the same command?

Yes: holding CapsLock and hitting b four times takes me back to the start of the
line…

I'm using urxvt{c,d}, bash and vi-mode.


What happens if you push esc-b? Maybe our escape keys behave differently.

Offline

#8 2012-10-27 03:28:53

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Holding the escape key

jasonwryan uses vi mode, whereas you are using emacs mode.  Try changing your xterm to vi mode and see if it works then.

Offline

#9 2012-10-27 04:18:50

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Holding the escape key

stewSquared wrote:
jasonwryan wrote:
stewSquared wrote:

Wait, really? And you ran the same command the same command?

Yes: holding CapsLock and hitting b four times takes me back to the start of the
line…

I'm using urxvt{c,d}, bash and vi-mode.


What happens if you push esc-b? Maybe our escape keys behave differently.

The same. Escape is Escape: wherever it is mapped...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#10 2012-10-27 11:33:39

stewSquared
Member
Registered: 2011-07-05
Posts: 16

Re: Holding the escape key

WonderWoofy wrote:

jasonwryan uses vi mode, whereas you are using emacs mode.  Try changing your xterm to vi mode and see if it works then.

Technically, I think it's changing bash (not xterm) to vi mode, but thanks -- I see what's happening now. M-b works how I'd like it to in vi mode, but I have no intention of using vi mode (I want emacs keybindings). I'd like the emacs-mode escape to behave like the vi-mode escape. Any suggestions as to how to do this?

Last edited by stewSquared (2012-10-27 13:01:32)

Offline

#11 2012-10-27 16:54:25

angelfalls
Member
Registered: 2012-03-26
Posts: 139

Re: Holding the escape key

What's about console (bash shell)? i tried to use loadkeys to remap caps lock to control and control to caps lock but it doesn't work, because i think use caps lock is easier than press control when i move around keyboard. so i wonder:
1. how can i remap caps lock to Control and Control to caps lock in bash (in tty)
2. how can i remap caps lock to ESC in vim (in tty)

I tried to modify /usr/local/share/kbd/keymaps/personal.map

keycode 58 = 29
keycode 29 = 58

58 is caps lock keycode
29 is control keycode.

Thanks in advanced!

Offline

#12 2012-10-27 21:44:19

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Holding the escape key

stewSquared wrote:

M-b works how I'd like it to in vi mode, but I have no intention of using vi mode (I want emacs keybindings). I'd like the emacs-mode escape to behave like the vi-mode escape. Any suggestions as to how to do this?

I should have looked more closely at this. In vi-mode, Escape (whatever it is bound to) puts you in command mode--and it only needs to be pressed once, therefore holding Escape and hitting b four times is the same as hitting Escape once and then hitting b four times.

I don't think that you can replicate modal behaviour in emacs mode, as it is a chordal paradigm. You can see all the readline bindings here:
http://linux.about.com/library/cmd/blcmdl3_readline.htm
you might find some way to hack it.

anglefalls wrote:

questions about keymapping...

Please don't hijack threads https://wiki.archlinux.org/index.php/Fo … _Hijacking

Start your own thread with  more information about your setup and what you have tried.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB