Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts / keyboard.js
blob: bacbea15e477940c6f1e79928b1bab863712cb25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
document.addEventListener('keydown', function (e) {
	if (e.ctrlKey) return;

	switch (e.code) {
		/* theme-changer.js */

		case 'KeyC':
			themeBtn.click();
			break;

		/* presentation.js */

		// Previous slide
		case 'KeyK': case 'Backspace': case 'PageUp':
		case 'ArrowLeft': case 'ArrowUp':
			showSlide(-1);
			break;
		// Next slide
		case 'KeyJ': case 'Space': case 'Enter': case 'PageDown':
		case 'ArrowRight': case 'ArrowDown':
			showSlide(+1);
			break;
		// Start (toggle) presenting
		case 'KeyP': case 'KeyT':
			togglePresentMode();
			break;
		// Exit presentation
		case 'Escape':
			if (presenting) togglePresentMode();
			break;
		// Go to first slide
		case 'Home':
			showSlide(-slideIndex);
			break;
		// Go to last slide
		case 'End':
			showSlide(-slideIndex -1);
			break;
	}
});