move to tinikeys and not allow start by keyboard
This commit is contained in:
@@ -19,6 +19,7 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
import type { IGameState } from '$lib/play/admin/game_state.ts';
|
import type { IGameState } from '$lib/play/admin/game_state.ts';
|
||||||
import { QuizQuestionType, type QuizData } from '$lib/quiz_types';
|
import { QuizQuestionType, type QuizData } from '$lib/quiz_types';
|
||||||
import type { Player, PlayerAnswer } from '$lib/admin';
|
import type { Player, PlayerAnswer } from '$lib/admin';
|
||||||
|
import { tinykeys } from '$lib/tinykeys';
|
||||||
|
|
||||||
navbarVisible.visible = false;
|
navbarVisible.visible = false;
|
||||||
|
|
||||||
@@ -123,6 +124,10 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
if (auto_connect) {
|
if (auto_connect) {
|
||||||
connect();
|
connect();
|
||||||
}
|
}
|
||||||
|
tinykeys(window, {
|
||||||
|
Enter: next_action,
|
||||||
|
Space: next_action
|
||||||
|
});
|
||||||
});
|
});
|
||||||
socket.on('session_id', (d) => {
|
socket.on('session_id', (d) => {
|
||||||
const session_id = d.session_id;
|
const session_id = d.session_id;
|
||||||
@@ -210,12 +215,8 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
);
|
);
|
||||||
|
|
||||||
// This function in called in every keyboard event in this page
|
// This function in called in every keyboard event in this page
|
||||||
const next_action = (e: KeyboardEvent) => {
|
const next_action = () => {
|
||||||
if (e.key in ['Enter', ' ']) return; // Don't catch events other than enter or spacebar
|
if (
|
||||||
|
|
||||||
if (game_state.is_game_ready_to_start()) {
|
|
||||||
socket_game_controls.start_game();
|
|
||||||
} else if (
|
|
||||||
game_state.is_active_question_last_question() &&
|
game_state.is_active_question_last_question() &&
|
||||||
(game_state.is_question_results_visible() || game_state.is_active_question_slide())
|
(game_state.is_question_results_visible() || game_state.is_active_question_slide())
|
||||||
) {
|
) {
|
||||||
@@ -237,7 +238,7 @@ SPDX-License-Identifier: MPL-2.0
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window onbeforeunload={confirmUnload} on:keydown={next_action} />
|
<svelte:window onbeforeunload={confirmUnload} />
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>ClassQuiz - Host</title>
|
<title>ClassQuiz - Host</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|||||||
Reference in New Issue
Block a user