I'm currently working with JavaFX key listeners. I'm able to identify keyboard input but my algorithm requires detecting the inactivity on keyboard. Is there a keycode or any other object that identifies inactivity?
Asked
Active
Viewed 112 times
-1
-
nothing fx version specific, so removed specialized tags – kleopatra Apr 06 '20 at 11:19
1 Answers
-1
Well, after a little research I found the answer. We can detect the inactivity by recording the difference between the time of the last activity and the current time.
For example:
double activityTime;
if(event){
activityTime = System.currentTimeMillis()*1000; // *1000 will convert milliseconds to seconds
}
if(System.currentTimeMillis()*1000 - activityTime > 5){
//This block will be triggered after 5 seconds of inactivity
//statements
}

Hamza Mahmood
- 17
- 7