how does a keylogger capture special keys

I wanna write a keylogger, but how to capture special keys like crt,alt,crt+v,crt+c,crt+alt+del,etc...
Anyone help me?
Last edited on
Those are not 'special keys'. Special keys are keys like the Fn keys for which the keyboard does not tell the computer about their existence or state.
so can you tell me how to do that?
How to do what? You cannot detect special keys such as the Fn key.
every key has a code, and when you first press Ctrl or Shfit and then the a key the code is different

For example (depends on whether the Caps Lock is on or not )

press Shfit + a -> code = 65
press a -> code = 97

Ctrl+ a -> code = 1

press c -> code = 99

Ctrl + c -> code = 3
Press Enter -> code = 13

Function keys have two codes first one and then another one

Press F1 -> code = 0 and 59

Press F12 -> code = ? and ? // try and find it :-)


Try and find it yourself,

1
2
3
4
5
int key = 0;
	while( key != 27) {// set whatever number you wish here :-), 27 =Esc
		key = getch();
		cout<<key<<endl;
	}

Last edited on
I'm pretty sure that shift and control are detected individually and in the same way as all other keys on the keyboard...using the console is a bad idea, what if they pressed control and C? ;)
@LB
Ctrl + c -> I did , and I get the code :-) , But the loop was like following


1
2
3
4
while( 64 < key < 99){
		key = getch();
		cout<<key<<endl;
}


If he uses a library or some thing like QT it is very easy to capture keyEvents, but if he is programming some console application without any library, so he may not have other options.
Last edited on
Thanks for help.
I used GetAsyncKeyState() in winuser.h
but my program only catches keys in ASCII

I wanna write a keylogger like this:
http://www.ematrixsoft.com/keylogger-spy-monitor-free-edition.htm

It's free but I want to write my keylogger :D
Last edited on
Topic archived. No new replies allowed.