The whole idea is to end the loop with the ESC button.
import java.util.Scanner; class Sum { public static void main(String[] args) { int sum = 0; System.out.println("Please write a number, end with ESC button"); Scanner in = new Scanner(System.in); int number = in.nextInt(); while (number != null ){ sum += number; System.out.println("Please write a number, end with ESC button"); } // end while System.out.println("The sumn is: "+ sum); } // end main } // end Sum