| Crates.io | kon_input |
| lib.rs | kon_input |
| version | 0.2.0 |
| created_at | 2026-01-17 12:07:40.675885+00 |
| updated_at | 2026-01-17 12:07:40.675885+00 |
| description | Input handling for the Kon Engine. |
| homepage | https://github.com/cey0225/kon |
| repository | https://github.com/cey0225/kon |
| max_upload_size | |
| id | 2050323 |
| size | 26,174 |
kon_input is the input handling module for Kon Engine. Provides unified keyboard, mouse, and action binding support with frame-accurate state tracking.
# Part of the kon-engine ecosystem
cargo add kon-engine
use kon::prelude::*;
#[system]
fn player_control(ctx: &mut Context) {
let input = ctx.input();
// Raw key/button queries
if input.is_key_pressed(KeyCode::Space) {
println!("Space held");
}
if input.just_button_pressed(MouseButton::Left) {
println!("Left click!");
}
// Action-based queries (recommended)
if input.just_action_pressed("Jump") {
println!("Jump triggered");
}
if input.is_action_pressed("MoveForward") {
println!("Moving forward...");
}
}
fn main() {
Kon::new()
.add_plugin(DefaultPlugins)
.add_system(player_control)
.run();
}
The default bindings cover common game actions, but you can add your own:
#[system]
fn setup_bindings(ctx: &mut Context) {
let mut input = ctx.input();
// Single key
input.add_binding("Crouch", InputSource::Key(KeyCode::LControl));
// Multiple keys for same action
input.add_binding("Interact", InputSource::Key(KeyCode::E));
input.add_binding("Interact", InputSource::Key(KeyCode::F));
// Mouse button
input.add_binding("Aim", InputSource::Mouse(MouseButton::Right));
// Key + Key chord
input.add_binding("QuickSave", InputSource::Chord(KeyCode::LControl, KeyCode::S));
// Key + Mouse chord
input.add_binding("ZoomShoot", InputSource::MouseChord(KeyCode::LShift, MouseButton::Left));
}
| Action | Default Binding |
|---|---|
MoveForward |
W, Up Arrow |
MoveBackward |
S, Down Arrow |
Jump |
Space |
Fire |
Left Mouse |
Sprint |
Left Shift |
SpecialSkill |
Left Shift + Right Mouse |
MIT OR Apache-2.0