You are not logged in.

#1 2017-06-18 02:13:22

mindstormer
Member
Registered: 2015-05-28
Posts: 28

Bind SHIFT key to unused key when pressed alone.

I use xcape to bind CAPS_LOCK key to ESC when pressed alone and to CTRL when held down and used like a modifier. This is a popular trick for those who use vim.

Now I want to bind SHIFT to an unused key when pressed alone (or a key that doesn't trigger anything in most if not all applications), for example maybe an F key like F30 or something. If it's used as a modifier, don't change its bindings (e.g. continue using SHIFT as you would typically use it as a modifier). The reason I want to do this is so I can use SHIFT as a leader key for both vim and emacs without any caveats. Popular leader keys for vim like SPACE or comma are not ideal because it might be bound to certain functions in certain modes in Emacs (ibuffer, magit, etc.).

So I execute the following:

xmodmap -e 'keycode 255=F30'
xcape -t 250 -e 'Shift_L=F30'

Using xev, pressing SHIFT alone shows up as F30 and keycode 255 (xmodmap -pk shows keycode 255 as empty). However, when I'm on a terminal (I use termite), if I press SHIFT alone on a string of command I typed out, it turns all the characters at and to the right of the cursor to uppercase if they were lowercase and vice versa. This behavior only occurs if tap SHIFT (held for ~1 second)--if held for longer, it doesn't do anything (which is what I want). The point of binding SHIFT to an unused key/function is that it is only usable in Emacs/Vim where I explicitly configured it to--I don't want unexpected behaviors that result from pressing SHIFT alone when I'm not in these programs. 

I tried binding it to other F keys and also using a different dummy keycode other than 255 but the same behavior occurs on the terminal.

Any ideas?

P.S. Someone said they were able to achieve something similar: https://www.reddit.com/r/emacs/comments … e/dj074re/

I have tried other terminals as suggested but to no avail.

Last edited by mindstormer (2017-06-18 03:17:39)

Offline

Board footer

Powered by FluxBB