Add keyboard shortcut for restarting the level

This commit is contained in:
Bocom 2020-10-04 00:57:07 +02:00
parent 8adb630862
commit ec67fc7bbb
2 changed files with 8 additions and 1 deletions

View File

@ -118,7 +118,7 @@
<div class="controls">
<div class="play-controls">
<button class="control-pause" type="button">Pause <span class="keyhint">(p)</span></button>
<button class="control-restart" type="button">Restart</button>
<button class="control-restart" type="button">Restart <span class="keyhint">(r)</span></button>
<button class="control-undo" type="button">Undo</button>
<button class="control-rewind" type="button">Rewind <span class="keyhint">(z)</span></button>
</div>

View File

@ -444,6 +444,13 @@ class Player extends PrimaryView {
}
}
if (ev.key === 'r') {
if (this.state === 'playing') {
this.restart_level();
return;
}
}
if (this.key_mapping[ev.key]) {
this.current_keys.add(ev.key);
ev.stopPropagation();