How to display output (W IS PRESSED) until i press w and when i release w then output will display as (W is released).
System.out.println("HI");
Scanner s = new Scanner(System.in);
String str = s.nextLine();
while(str.equals("w"))
{
System.out.println("W IS PRESSED");
}