[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use the "windows" key as the escape key

From: Erik Falor
Subject: Re: use the "windows" key as the escape key
Date: Tue, 29 Dec 2009 11:47:41 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

On Mon, Dec 28, 2009 at 09:03:50AM -0600, Dustin Kirkland wrote:
> I have been asked this several times and I haven't been able to find
> the answer myself.
> Is it possible to use the "Windows" key (Super_L) (between Ctrl and
> Alt) as the screen escape key?  If so, how do you set this in your
> .screenrc?

I'll take a stab at this.

Assuming you're running Linux, there are two cases to consider:

1. Using one of your Virtual Consoles (Ctrl-Alt-Fn)
In the Linux virtual console, I think you stand a better chance.  As
root, you can run showkey, which will show you the keycode which
corresponds to your windows keys.  On my laptop, Super_L is 125 and
Super_R is 126.

Then you can run dumpkeys to see what actions are taken when these
keys are pressed:

# dumpkeys | grep -E "keycode *125|126"
keycode  125 = 
keycode  126 = 

This means that the keymap the kernel loads doesn't emit anything when
these keys are pressed.

You can use the loadkeys program to map the keycodes to another key,
or to map them to emit a string of your choosing.

The code looks like this:
# loadkeys - <<EOF
> keycode 125 = F60 F61 F62 F63 F64 F65
> string F60 = "F60"
> string F61 = "F61"
> string F62 = "F62"
> string F63 = "F63"
> string F64 = "F64"
> string F65 = "F65"

Now, when you hit Super_L in the virtual console, the string F60 is
entered for you.  Shift+Super_L yields F61.  Ctrl+Super_L yields F64,
which is the sequence you'll care about.  You should read `man loadkeys`.

2. Running a virtual terminal from X (such as xterm or rxvt)

I think it is not possible in this case because the terminal never
sees the keycode Super_L generates.  It is usually intercepted by your
window manager before being passed to an application.  However, you
might be able to hack your X keyboard map to re-map Super_L into
something that would be passed onto your application by your window
manager.  But, that may also cause Super_L to lose its super meaning
for any other apps that may wish to use it.

Basically, it would mean that you edit one or more of the files
setxkbmap uses to build up your keyboard map, an operation equivalent
to what I described in case 1 using loadkeys.  The webpages at [0] and
[1] will be of help for that task.

Once you have the Super_L key acting more like its merely mortal
bretheren, you'll still need to tell .screenrc how to recognize it.

The way I do this is to (outside of screen!) fire up Vim, press i to
enter insert mode, and press ctrl-V to instruct Vim to take the next key 
sequence literally.  I then type ctrl-whatever to see
how it looks to the terminal.  I do this in Vim instead of Bash,
because I find that Vim echoes back more keys than will Bash.  For
instance, I like to use Ctrl-space as my screen escape key.  Typing
this literally into Vim results in address@hidden

The appropriate entry in my .screenrc is, therefore, 
escape ^@@

If I want to use ctrl-backslash, the .screenrc entry is
escape ^\\

I hope this at least points you in the right direction.


Erik Falor
Registered Linux User #445632

Attachment: signature.asc
Description: Digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]