All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jme3.input.package.html Maven / Gradle / Ivy

There is a newer version: 3.7.0-stable
Show newest version









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");





© 2015 - 2024 Weber Informatics LLC | Privacy Policy