Skip to content

API to view raw winit events (particularly keyboard inputs) #3266

@HactarCE

Description

@HactarCE

Is your feature request related to a problem? Please describe.

In Hyperspeedcube (repo, website, online demo) the user has the ability to bind keys to scancodes rather than keycodes, which use my key-names crate to abstract over platform specifics. I would love to use eframe for Hyperspeedcube, but I need access to low-level keyboard input information. I even want platform-specific keys, so that users can bind every key on their keyboard for speedsolving.

This is also useful for first-person games or 3D movement controls where position on the keyboard matters more than keycode, so controls should use scancodes rather than keycodes to be more keyboard-layout-independent.

Describe the solution you'd like

I would like some API for accessing raw winit events, or at least keyboard events, when using eframe with winit. These events will necessarily be platform-specific, but that's ok as it's an escape hatch like EventLoopBuilderHook.

For maximum flexibility, this could be a handler that can alter, delete, or construct winit events to be sent to eframe, but really all I need is to see them at some point during the frame so that I can do my own handling. Some of my users have wanted to bind the tab key, but this is reserved in egui for accessibility reasons. If I could, I'd add an option to my application to override the tab key in certain contexts if the user has bound a custom action to it.

Describe alternatives you've considered

  • Currently I'm using pure egui+winit+wgpu and handling all the glue code myself just because of this one essential feature.
  • Alternatively, egui could provide scancode information in its own data structures for handling input. This is not my preferred option, as it's really hard to support everything I want on all platforms, and I need features that egui doesn't provide such as platform-dependent key names and keyboard layout information (which is only accessible on Windows and Linux).
  • egui could also fully embrace and/or adopt the key-names crate with all its features. I didn't write that crate with widespread use in mind (it's not even on crates.io) but that is an option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions