Also, the first result for googling "java key pressed event" is a part of the tutorial I already linked you.
Type: Posts; User: KevinWorkman
Also, the first result for googling "java key pressed event" is a part of the tutorial I already linked you.
I've asked you several times to read the tutorial. It contains information on many kinds of listeners, including KeyListeners and MouseListeners.
Then you need to post exactly what you don't understand.
For more info on the underlying workings of Events, read the tutorials: Lesson: Writing Event Listeners (The Java™ Tutorials > Creating a GUI With JFC/Swing)
And just look at how your parenthesis...
You can do it a number of ways. Declare it as a separate class, or implement it using the same class, or instantiate an anonymous inner class. Try one, post what you've tried, and we'll go from...
Recommended reading: How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)