1
1
mirror of https://github.com/jxnblk/mdx-deck.git synced 2024-09-17 09:57:23 +03:00

fix: Stop slides keyboard navigation if user might be typing

This commit is contained in:
Andrey Okonetchnikov 2020-04-11 16:07:06 +02:00
parent d3cea6b44a
commit 3554159464

View File

@ -16,6 +16,8 @@ const keys = {
pageDown: 34,
}
const inputElements = ['input', 'select', 'textarea', 'a', 'button']
export const useKeyboard = () => {
const context = useDeck()
@ -24,6 +26,10 @@ export const useKeyboard = () => {
if (e.metaKey) return
if (e.ctrlKey) return
// ignore custom keyboard shortcuts when elements are focused
const el = document.activeElement.tagName.toLowerCase()
if (inputElements.includes(el)) return
if (e.altKey) {
switch (e.keyCode) {
case keys.p: