mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-03 17:58:49 +00:00
LibWeb: Allow changing media volume with keyboard controls
This allows increasing and decreasing the media volume by 10% with the up and down arrow keys, respectively. This also allows toggling the mute state with the M key.
This commit is contained in:
parent
6a5229c2cb
commit
720d8889ad
Notes:
sideshowbarker
2024-07-17 01:04:03 +09:00
Author: https://github.com/trflynn89
Commit: 720d8889ad
Pull-request: https://github.com/SerenityOS/serenity/pull/19771
1 changed files with 18 additions and 0 deletions
|
@ -1885,6 +1885,24 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::handle_keydown(Badge<Web::EventHandl
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case KeyCode::Key_Up:
|
||||||
|
case KeyCode::Key_Down: {
|
||||||
|
static constexpr double volume_change_per_key_press = 0.1;
|
||||||
|
auto volume = this->volume();
|
||||||
|
|
||||||
|
if (key == KeyCode::Key_Up)
|
||||||
|
volume = min(1.0, volume + volume_change_per_key_press);
|
||||||
|
else
|
||||||
|
volume = max(0.0, volume - volume_change_per_key_press);
|
||||||
|
|
||||||
|
TRY(set_volume(volume));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case KeyCode::Key_M:
|
||||||
|
set_muted(!muted());
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue