Instructions
- 1
Open the Java editor that you use to write your code and load up the project you want to edit. Double-click on your Java source code file.
2Add the event handler that detects when a user presses a key. The following Java code detects each key press:
public boolean mouseDown( Event evt, int x, int y)
The Java code that you want to execute when the key is pressed is placed within the brackets.
3Add code to the event handler. The following example echoes the keystroke back to the user:
System.out.println("You pressed the " + evt.key + " key.");
No comments:
Post a Comment