You match the modifiers separately, using the modifiers field of the KeyPressed event. Putting it all together, it would look like this:
match event {
iced::Event::Keyboard(iced::keyboard::Event::KeyPressed {
key: iced::keyboard::Key::Character(c),
modifiers: iced::keyboard::Modifiers::CONTROL,
..
}) if c == "s" => { // You could test for `c.to_lowercase() == "s"` if you care for both cases
// Ctrl+s was pressed
},
@lufte but don’t I first need to listen for Control key, and then listen for s. I want to listen Control + s. Not s and then a modifier key (it also said that Control can’t be a modifier key).
Ah, no, you don’t need to keep track of whether the modifier keys were pressed (and not released!) before or not; Iced does that for you and can inform you if they are pressed (through the modifiers field) when another key is pressed.
My example is reacting to a key press of the letter s if, and only if, the Ctrl key is also pressed (with no other modifiers).
I made a mistake in my code though, I used Modifiers::SHIFT when I meant Modifiers::CONTROL. It’s fixed now.