Hey Ruby, you can press Escape key on keyboard using these robot class methods:
- 
keyPress(): Press Escape key from KeyBoard using keyPress method.
robot.keyPress(KeyEvent.VK_ESC);
 
- 
keyRelease(): Using this method we Release any pressed key from Keyboard.
robot.keyRelease(KeyEvent.VK_ESC);
 
- 
mousePress(): Using mousePress() Method we press Left mouse button from Mouse.
robot.mousePress(InputEvent.BUTTON1_MASK);
 
- 
mouseRelease(): Using mouseRelease() Method we Release pressed Left mouse button from Mouse.
robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
- 
mouseMove(): mouseMove() Method Move cursor pointer to X and Y co-ordinates.
robot.mouseMove(coordinates.getX(), coordinates.getY());