Feb 28, 2012 at 12:41pm UTC
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 Feb 28, 2012 at 12:44pm UTC
Feb 28, 2012 at 2:43pm UTC
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.
Feb 28, 2012 at 3:08pm UTC
so can you tell me how to do that?
Feb 28, 2012 at 3:22pm UTC
How to do what? You cannot detect special keys such as the Fn key.
Feb 28, 2012 at 3:23pm UTC
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 Feb 28, 2012 at 3:39pm UTC
Feb 28, 2012 at 10:30pm UTC
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? ;)
Feb 29, 2012 at 12:30am UTC
@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 Feb 29, 2012 at 1:11am UTC
Feb 29, 2012 at 1:19pm UTC
Last edited on Feb 29, 2012 at 1:21pm UTC