I am writing a program which need to listen the user keyboard stroks.

I use function XGrabKeyboard() and this is my code:

```
XGrabKeyboard(pDisplay, DefaultRootWindow(pDisplay), True, GrabModeAsync, GrabModeAsync, CurrentTime);
XEvent event;
while (true)
{
  XNextEvent(pDisplay, &event);
  switch (event.type)
  {
  ...
  }
}

```

But it causes the keyboard and cursor to be frozen.

I looked up the man page, it only says: "The third parameter specifies a Boolean value that indicates whether the keyboard events are to be reported as usual."

I tried both true or false or the 3rd param, both GrabModeAsync and GrabModeSync for the 4th and 5th param, but it doesn't work.

After calling XGrabKeyboard(), the keyboard is frozen and mouse click doesn't response.

Any ideas?