The com.jme3.input package is used for all input handling in jMonkeyEngine. User code should use the {@link com.jme3.input.InputManager} to register for and receive input events. The InputManager can be retrieved for an application by using {@link com.jme3.app.Application#getInputManager()}.

Usage

Using ActionListener:
// Retrieve an input manager for the application "app"
InputManager inputManager = app.getInputManager();

// Adds a new mapping "PrintHello" that will be invoked when the Return/Enter key is pressed
inputManager.addMapping("PrintHello", new KeyTrigger(KeyInput.KEY_RETURN));
// Adds a new ActionListener to get an event when enter is pressed.
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
// Only invoke the event when the mapping is "PrintHello"
// and isPressed is true, meaning it was a key press and not release.
if (name.equals("PrintHello") && isPressed){
System.out.println("Hello!");
}
}
}, "PrintHello");