If you mean that you wanna attach this to your panel (Window that you are working with).
then you have to create an inner class that extend from IKeyListener interface and then add that method in to the class.
Then, attach that class to you panel by: this.addKeyListener(new subclass());