Coder Social home page Coder Social logo

Comments (6)

kchibisov avatar kchibisov commented on May 28, 2024

The button itself has a position attached to it, so you can detect from KeyEvent whether you've pressed left/right shift. There's no state as double/single shift, because it doesn't matter.

If you want to detect double shift, check for Shift with the Shift modifier applied to it.

So from what I can say everything is detected and consistent, unless you don't have KeyboardInput for left/right shift when you press them.

from winit.

junglie85 avatar junglie85 commented on May 28, 2024
[age\src\app.rs:165] &event = KeyEvent {
    physical_key: Code(
        ShiftLeft,
    ),
    logical_key: Named(
        Shift,
    ),
    text: None,
    location: Left,
    state: Pressed,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: Named(
            Shift,
        ),
    },
}
[age\src\app.rs:165] &event = KeyEvent {
    physical_key: Code(
        ShiftRight,
    ),
    logical_key: Named(
        Shift,
    ),
    text: None,
    location: Right,
    state: Pressed,
    repeat: true,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: Named(
            Shift,
        ),
    },
}
[age\src\app.rs:165] &event = KeyEvent {
    physical_key: Code(
        ShiftLeft,
    ),
    logical_key: Named(
        Shift,
    ),
    text: None,
    location: Left,
    state: Released,
    repeat: false,
    platform_specific: KeyEventExtra {
        text_with_all_modifers: None,
        key_without_modifiers: Named(
            Shift,
        ),
    },
}

But these are 2 separate keys, so I'd expect 2 pressed events and 2 released events. Yes, there are 2 pressed events, but why is the second a repeat, when it is a different key?

from winit.

kchibisov avatar kchibisov commented on May 28, 2024

That just sounds like a windows specific issue, which you should open a separate issue for.

The modifiers are delevired via the ModifiersChanged event anyway.

from winit.

junglie85 avatar junglie85 commented on May 28, 2024

So why have modifier info in both keyboard input and modifier changed events? That's pretty confusing.

from winit.

junglie85 avatar junglie85 commented on May 28, 2024
[age\src\os.rs:270] _modifiers = Modifiers {
    state: ModifiersState(
        SHIFT,
    ),
    pressed_mods: ModifiersKeys(
        0x0,
    ),
}
[age\src\os.rs:271] _modifiers.lshift_state() == winit::keyboard::ModifiersKeyState::Pressed = false
[age\src\os.rs:272] _modifiers.rshift_state() == winit::keyboard::ModifiersKeyState::Pressed = false
[age\src\os.rs:270] _modifiers = Modifiers {
    state: ModifiersState(
        0x0,
    ),
    pressed_mods: ModifiersKeys(
        0x0,
    ),
}
[age\src\os.rs:271] _modifiers.lshift_state() == winit::keyboard::ModifiersKeyState::Pressed = false
[age\src\os.rs:272] _modifiers.rshift_state() == winit::keyboard::ModifiersKeyState::Pressed = false

So it's not possible to get a modifier changed notification when a different version of the modifier is already down? Nor is it possible to know which one is held down?

from winit.

kchibisov avatar kchibisov commented on May 28, 2024

So why have modifier info in both keyboard input and modifier changed events? That's pretty confusing.

Button press like Shift doesn't mean that the modifier is actually pressed, button release of Shift, doesn't mean that modifier was released. Consider for example sticky keys, which you get by press/release the Shift, and then the next key is with Shift modifier, however the Shift itself is no longer held.

So if you want to get a regular button, you use key itself, it may not be a modifier at all, but you care about a button, so it doesn't matter.

If you want to work with modifiers, as in, with the bindings, you use the ModifiersChanged event.

Yes, maybe on windows, it's not like that, but on linux modifiers and keys itself are detached, the modifier can also change for synthetic input without any change in the modifier itself.

So it's not possible to get a modifier changed notification when a different version of the modifier is already down? Nor is it possible to know which one is held down?

Yes, because there's no change, pressing more shift won't make a change because you already are holding a shift(you can try to detect left/right shift if you really want to), relying on this behavior is error prone, because on linux (xkbcommon) once you press modifier one more time there's no change in modifiers state at all.

from winit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.