You are not logged in.

#1 2012-08-30 16:31:51

jmartl109
Member
Registered: 2011-03-17
Posts: 25

Modifier-free (global) keybindings

Currently, I have a lot of keybindings in awesome wm and xbindkeys that do things like map Super + k to raise an xterm. What I'd like is a keybinding that maps "jk" to do this -- one which doesn't impede my ability to type other words with j's in them.

I've tried/thought about xbindkeys, xdotool, and awesome's keygrabber module, and with all of them I end up with the following general problem: I'm trying to remap "j" to a function that does (pseudocode):

if nextKey == "k"
        then execute "xterm"
else press "j", nextKey

where the last line is obviously problematic.

The idea was inspired by vim on two counts:
(1) basically the point is that there are better alternatives to hitting modifier keys all the time;
(2) I can do

 imap jk <something> 

and it Does The Right Thing.
However, I don't want WM-wide modal keybindings, because that would still mean pressing extra keys; what I want is vim's "imap", only globally.

I can't believe I'm the only one who's wanted this, and so I'm wondering if anyone here has managed to come up with a solution.

Offline

#2 2012-08-30 16:51:45

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

Re: Modifier-free (global) keybindings

I suppose it'd be pretty easy to write a little tool that runs in the background and "filters" all keypresses and could do something like this.  But if it's modeless, I imagine that'd be a real PITA to use.

What if you want to type the letters "jk" in a document, or email ... or use them in vim!  Suddenly your previously desired global mapping is getting in the way.


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

Offline

#3 2012-08-31 05:01:15

jmartl109
Member
Registered: 2011-03-17
Posts: 25

Re: Modifier-free (global) keybindings

I was imagining something with a timeout, like vim's imap. Not sure why this would be a PITA; again, in vim I have a lot of things like "imap jk <esc>" with a short-ish timeout and they never get in my way...

I guess I could look at Xlib, but (a) I was hoping there was a higher-level tool that could do things like this, because I'm really not a programmer, and (b) I still don't see how to get around the problem I hinted at above: if I have a keybinding for "jk", then that means I'm capturing presses of "j"; if I type "je" instead, then the program would have to emit "j" and "e" keypresses, and this "j" keypress would get captured again by my program, ad infinitum.

Offline

Board footer

Powered by FluxBB