Keysym to modifiers state

Cvetelin Andreev cvetelin.a at komero.net
Tue Nov 1 08:33:32 PST 2005


You can try this


#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>

Display* kdpy;
Window kroot;

main(argc,argv)
     int argc;
     char **argv;
{
     /* Open the display */
     if ((kdpy = XOpenDisplay(NULL)) == NULL) {
         (void) fprintf(stderr, "%s: can't open %s\n",
                              argv[0], XDisplayName(NULL));
         exit(1);
     }

     kroot = XDefaultRootWindow(kdpy);

     KeyCode first = XKeysymToKeycode(kdpy, XK_a);
     KeyCode second = XKeysymToKeycode(kdpy, XK_A);

     printf("First is 0x%x, second is 0x%x\n", first, second);
     XCloseDisplay(kdpy);
}


The result on my computer is:

First is 0x26, second is 0x26

On Tue, 01 Nov 2005 18:19:04 +0200, Cvetelin Andreev  
<cvetelin.a at komero.net> wrote:

> XKeysymToKeycode functions returns the keycode for the keysym, it does  
> not tell you whether Shift is pressed or not.
>
> On Tue, 01 Nov 2005 18:00:18 +0200, Jim Gettys <jg at freedesktop.org>  
> wrote:
>
>> XKeysymToKeycode
>
>
>



-- 
Cvetelin Andreev



More information about the xorg mailing list