User Input Listener Strategy

Hello im new here and i dont really know if this question is newbie related…but im recently implemented a new listener strategy in my engine.

Its really simple, a class ListenerManager(implements every input listener) has a arraylist for each type of input(mouse moved, key pressed…), a static MouseEvent and a static KeyEvent.
A function init() adds the ListenerManager as listener in the contentPane, oh im using Java2d with a JFrame as window
Every input call the KeyEvent or MouseEvent is updated and the ActionListeners are called in order.

Code example:


ListenerManager.addListenerToLlist(ListenerManeger.KEY_PRESSED, new ActionListener() {
    public void performAction(ActionEvent e) {
         if (ListenerManager.keyInput.getKeyCode() == KeyEvent.VK_SPACE) {
                System.out.println("Space was pressed");
         }
    }
});


I want to know if there is other ways of implementing this and if this strategy has any flaws;

You might want to encode the key pressed in ActionEvent e, such that the event method is self contained. You can then add other properties, like if the key pressed is a repeat event for example

yeah im planning on doing this, creating a interface MouseListener and KeyListener for passing the MouseEvent and KeyEvent as parameters. I might post my project later today.

I made a keyboard manager thing way back that uses procedural inputs and executes code based off that gathered input.

What you should do is modify it so that all keys pressed and released get passed to the code. It’s worth to study if you have no idea how the code would be implemented at a low level standpoint. I am here for questions.

KeyState.java - http://pastebin.java-gaming.org/9f6bb7c094511
KeyListener.java - http://pastebin.java-gaming.org/f6bbc8905411f
KeyboardManager.java - http://pastebin.java-gaming.org/6bbc995014f18

Thanks! I will take a look.