I'm developing a code to get keyboard input in KeyPress and KeyRelease events, but when i run the program nothing happens, what is wrong with my code? And how to get the pressed key value?
void hook()
{
forever
{
XEvent event;
Display *dpy = XOpenDisplay(NULL);
XNextEvent(dpy, &event);
switch (event.type)
{
case KeyPress:
qDebug() << "keypress";
break;
case KeyRelease:
qDebug() << "keyrelease";
break;
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…