Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts / keyboard.js
blob: f5ed9341d36e2dd0150648db8c1a9709f3e65561 (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
41
42
43
44
45
46
document.addEventListener('keydown', function (e) {
	if (e.ctrlKey) return;
	if (e.target != document.body) return;

	switch (e.code) {

		case 'KeyC': // theme-changer.js
			themeBtn.click();
			break;
		case 'KeyW': // page-width.js
			widthBtn.click();
			break;
		case 'KeyE': // expand-navbar.js
			expandBtn.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;
	}
});