Warning
This plugin is in early development and should be considered experimental. Expect frequent changes, incomplete features, and breaking updates.
Contributions and feedback are welcome, but use in production is not recommended until a stable version is tagged.
Track progress and open issues here: GitHub Issues
An input plugin for Phaser 3 inspired by Unreal Engine’s Enhanced Input system. Supports mapping keyboard input to named actions, with context-based grouping and optional lifecycle callbacks.
npm install phaser-plugin-enhanced-input
import {EnhancedInputPlugin} from 'phaser-plugin-enhanced-input';
new Phaser.Game({
// ...
plugins: {
scene: [
{
key: 'enhancedInput',
plugin: EnhancedInputPlugin,
mapping: 'enhancedInput',
}
]
}
});
import {InputMappingContext} from 'phaser-plugin-enhanced-input';
const weaponContext = new InputMappingContext(this, {
fire: {
binding: Phaser.Input.Keyboard.KeyCodes.SPACE,
pressed() {
console.log('fire pressed');
},
held() {
console.log('fire held');
},
released() {
console.log('fire released');
},
},
});
this.enhancedInput.addMappingContext(weaponContext);
this.enhancedInput.enableMappingContext(weaponContext);
// Or
weaponContext.enable();
// Later...
this.enhancedInput.disableMappingContext(weaponContext);
// Or
weaponContext.disable();
.enable()
– Attach all bindings and begin listening for events.disable()
– Detach listeners without destroying state.destroy()
– Clean up all resources- Access bindings via dot notation:
context.fire.pressed(() => ...)