Kind of depends. Are you using JFrame without a game library or framework? If so then you want to call the method `addKeyListener(ListenerObjectHere)` or `addMouseListener(ListenerObjectHere)` on the JFrame. Then the listeners you just created should Implement `KeyListener` or `MouseListener`. If you're using a game framework it should have a polling system instead of events, which I'm not sure how to get around (Unless you could obtain the JFrame). If this is the case, just check each update (or tick) if a button is pressed.