Keymappings (not fvwm-specific)

Anyone have any ideas on how I might go about setting up my system such that when the numlock key is on, the h is the left arrow, the j is the down arrow, the k is the up arrow, and the l is the right arrow?

I don’t think Xmodmap can do it (unless I’m not understanding the man page), and other than that I wasn’t sure where to look.

put vim as shell :laughing:

or better yet, vi

(seriously, don’t)

Actually, I already set -o vi in my .bashrc, but I need an X windows solution :slight_smile:

It is rather complicated, but using XTest extension, you can send fake KeyEvent which are generated as true key event (not as with XSendEvent which is ignored by xterm).

Hence, you can bind mod2+ijkl (mod2 = numlock on my computer) to the program to sends a fake key event. The program (need to add error checking) could be

[code]/* compile with:
gcc -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXtst -Wall
#include <X11/extensions/XTest.h>

int main(int argc,char **argv) {
Display *dpy = XOpenDisplay(NULL);
int keycode = atoi(argv[1]);
return 0;
and could be fine tuned to actually send a Press event when the key is pressed (True as the third parameter of XTestFakeKeyEvent) and Realease when the key is released.

by the way, it also works to send fake mouse event. I found usefull to bind a middleclick to a key to be able to paste text easily. The function to call is XTestFakeButtonEvent(Display *dpy, int buttonNb, Bool PressedOrReleased, int time).

The sample code you provided worked perfectly, thanks. I’ll be using it until I find a way to actually set up keymappings.

I’ll be incorporating that second bit on my iBook. I get seriously annoyed at not having a good way to copy and paste amongst different applications on there, only one button and no insert key or other free key to be mapped.


I don’t know how it is on ibooks, but on my apple keyboard, I had F13 F14 and F15 which were not used (though I had to patch kbd driver from xfree86 to make them work), and used them as left, middle and right click. No use for a 3 button mouse :wink: