I am trying to write a C program which is aware of the control / alt / shift key being pressed down. I found something that provides this functionality in Java, but that's not helping me too much.
void CMousepresentView::OnDraw(CDC* pDC)
{
int shiftValue=::GetKeyState(VK_SHIFT);
if(!shiftValue)
pDC->TextOut(0,50,"Shift not pressed");
else
pDC->TextOut(0,50,"Shift pressed");
int ctrlValue=::GetKeyState(VK_CONTROL);
if(!ctrlValue)
pDC->TextOut(0,100,"Ctrl not pressed");
else
pDC->TextOut(0,100,"Ctrl pressed");
}
So what I have so far is quite rudimentary but I must start somewhere. It doesn't work though, at all.
#include <stdio.h>
#include <ctype.h>
int main(void)
{
char ch;
do {
ch = getchar();
putchar(ch);
} while(iscntrl(ch));
return 0;
}
I was hoping that iscntrl would at least give me some reaction from the system to start debugging and identifying the control sequence keypresses. No such luck.
If I could see an example that outputs "control is pressed / control is released", I could probably figure out the rest.
Update:
Have had some progress with this http://www.thelinuxdaily.com/2010/05/grab-raw-keyboard-input-from-event-device-node-devinputevent/
Update:
I think the answer is in using xlib. Thanks everyone.