Add better event handlers

This commit is contained in:
schmelczerandras 2020-11-22 21:35:44 +01:00
parent d07102077f
commit 6fc16f4de0

View file

@ -12,7 +12,7 @@ import './styles.scss';
import { create } from './portfolio';
const addSupportForTabNavigation = () =>
(document.onkeydown = e => {
document.addEventListener('keydown', e => {
if (e.key === ' ') {
(document.activeElement as HTMLElement)?.click();
e.preventDefault();
@ -20,8 +20,11 @@ const addSupportForTabNavigation = () =>
});
const removeUnnecessaryOutlines = () =>
(document.onclick = () => (document.activeElement as HTMLElement).blur?.());
document.addEventListener('click', () =>
(document.activeElement as HTMLElement).blur?.()
);
create();
addSupportForTabNavigation();
removeUnnecessaryOutlines();
create();