Skip navigation links

Package com.jme3.input

The com.jme3.input package is used for all input handling in jMonkeyEngine.

See: Description

Package com.jme3.input Description

The com.jme3.input package is used for all input handling in jMonkeyEngine. User code should use the InputManager to register for and receive input events. The InputManager can be retrieved for an application by using 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");

Skip navigation links