Java: Below I have Written a code in which if user enter escape key then the loop has to be terminate..but it doesn't work on escape key
Code
import java.util.Scanner;
public class While {
public static void main(String args[]){
Scanner scan = new Scanner(System.in);
char ch=' ';
while (ch!=27){ // 27 is ASCII code For 'Escape' Key.
System.out.println("Input Any Character ");
ch =scan.next().charAt(0);
}
System.out.println("End of Loop");
}
}