keyboard - Using KeyLoggers in Java -


i trying implement key loggers in java using jnative hook.i 'm able record every key movement.this output able till now

when i'm trying type "facebook" how recording

 f   c  e  b  o  o  k 

but want print single word every other keylogger does. means when enter facebook.it should record "facebook" not recording every keyboard char.

below posted code:

public class key_logger implements nativekeylistener {  @override public void nativekeypressed(nativekeyevent nativekeyevent) {      system.out.print(nativekeyevent.getkeychar());  if(nativekeyevent.getkeycode()== nativekeyevent.vk_escape) {     //system.out.println("ter");     globalscreen.unregisternativehook(); } }  @override public void nativekeyreleased(nativekeyevent nativekeyevent) {   }  @override public void nativekeytyped(nativekeyevent nativekeyevent) {      system.out.println(nativekeyevent.getkeychar());  }  public static void main(string[] args) {     try     {       globalscreen.registernativehook();     } catch (nativehookexception e) {         system.out.println("there problem registering hook");         e.printstacktrace();         system.exit(1);     }      globalscreen.getinstance().addnativekeylistener(new key_logger());  } } 

store characters in string , whenever come across enter or spacebar being pressed print string make sure reinitialize string

   string string ="";     @override public void nativekeytyped(nativekeyevent nativekeyevent) {     string.append(nativekeyevent.getkeychar());     if(nativekeyevent.getkeycode()=='key code enter' && nativekeyevent.getkeycode()== 'key code space'){         system.out.println(string);         string="";    } } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -