How to use the is-hotkey.isHotkey function in is-hotkey

To help you get started, we’ve selected a few is-hotkey examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Malvid / Malvid / src / client.js View on Github external
// Parse the initial location
	parseLocation(history.location)

	// Reparse the location when the user navigates
	history.listen(parseLocation)

	const html = h(Provider, { store }, h(Main))
	const root = document.querySelector('#main')

	render(html, root)

	// Curry the hotkey string for better performance
	const isClearKey = isHotkey('esc')
	const isConfirmKey = isHotkey('enter')
	const isPrevKey = isHotkey('up')
	const isNextKey = isHotkey('down')

	const navigateTo = (nextComponent, nextTab) => {

		if (nextComponent == null) return

		location.href = createRoute(nextComponent.id, nextTab.id)

	}

	const clearFilter = () => store.dispatch(setFilter(''))
	const focusFilter = () => document.querySelector('#filter').focus()

	document.documentElement.onkeydown = (e) => {

		const state = store.getState()
		const { components, filter, currentComponent, currentTab } = enhanceState(state)
github Malvid / Malvid / src / client.js View on Github external
}

	// Parse the initial location
	parseLocation(history.location)

	// Reparse the location when the user navigates
	history.listen(parseLocation)

	const html = h(Provider, { store }, h(Main))
	const root = document.querySelector('#main')

	render(html, root)

	// Curry the hotkey string for better performance
	const isClearKey = isHotkey('esc')
	const isConfirmKey = isHotkey('enter')
	const isPrevKey = isHotkey('up')
	const isNextKey = isHotkey('down')

	const navigateTo = (nextComponent, nextTab) => {

		if (nextComponent == null) return

		location.href = createRoute(nextComponent.id, nextTab.id)

	}

	const clearFilter = () => store.dispatch(setFilter(''))
	const focusFilter = () => document.querySelector('#filter').focus()

	document.documentElement.onkeydown = (e) => {
github Malvid / Malvid / src / client.js View on Github external
// Parse the initial location
	parseLocation(history.location)

	// Reparse the location when the user navigates
	history.listen(parseLocation)

	const html = h(Provider, { store }, h(Main))
	const root = document.querySelector('#main')

	render(html, root)

	// Curry the hotkey string for better performance
	const isClearKey = isHotkey('esc')
	const isConfirmKey = isHotkey('enter')
	const isPrevKey = isHotkey('up')
	const isNextKey = isHotkey('down')

	const navigateTo = (nextComponent, nextTab) => {

		if (nextComponent == null) return

		location.href = createRoute(nextComponent.id, nextTab.id)

	}

	const clearFilter = () => store.dispatch(setFilter(''))
	const focusFilter = () => document.querySelector('#filter').focus()

	document.documentElement.onkeydown = (e) => {

		const state = store.getState()
github Malvid / Malvid / src / client.js View on Github external
}

	// Parse the initial location
	parseLocation(history.location)

	// Reparse the location when the user navigates
	history.listen(parseLocation)

	const html = h(Provider, { store }, h(Main))
	const root = document.querySelector('#main')

	render(html, root)

	// Curry the hotkey string for better performance
	const isClearKey = isHotkey('esc')
	const isConfirmKey = isHotkey('enter')
	const isPrevKey = isHotkey('up')
	const isNextKey = isHotkey('down')

	const navigateTo = (nextComponent, nextTab) => {

		if (nextComponent == null) return

		location.href = createRoute(nextComponent.id, nextTab.id)

	}

	const clearFilter = () => store.dispatch(setFilter(''))
	const focusFilter = () => document.querySelector('#filter').focus()

	document.documentElement.onkeydown = (e) => {
github edtr-io / edtr-io / packages / plugins / text / src / plugins / rich-text.tsx View on Github external
onKeyDown(event, editor, next) {
      const e = (event as unknown) as KeyboardEvent
      if (isHotkey('mod+b')(e)) {
        e.preventDefault()
        return toggleStrong(editor)
      } else if (isHotkey('mod+i')(e)) {
        e.preventDefault()
        return toggleEmphasize(editor)
      } else if (isHotkey('mod+q')(e)) {
        e.preventDefault()
        return toggleCode(editor)
      }

      return next()
    },
github edtr-io / edtr-io / packages / plugins / text / src / plugins / rich-text.tsx View on Github external
onKeyDown(event, editor, next) {
      const e = (event as unknown) as KeyboardEvent
      if (isHotkey('mod+b')(e)) {
        e.preventDefault()
        return toggleStrong(editor)
      } else if (isHotkey('mod+i')(e)) {
        e.preventDefault()
        return toggleEmphasize(editor)
      } else if (isHotkey('mod+q')(e)) {
        e.preventDefault()
        return toggleCode(editor)
      }

      return next()
    },
github edtr-io / edtr-io / packages / plugins / text / src / plugins / katex / index.tsx View on Github external
onKeyDown(event, editor, next) {
      const e = event as KeyboardEvent
      if (isHotkey('mod+m')(e)) {
        e.preventDefault()
        return insertKatex(editor)
      }
      return next()
    },
github edtr-io / edtr-io / packages / plugins / text / src / plugins / rich-text.tsx View on Github external
onKeyDown(event, editor, next) {
      const e = (event as unknown) as KeyboardEvent
      if (isHotkey('mod+b')(e)) {
        e.preventDefault()
        return toggleStrong(editor)
      } else if (isHotkey('mod+i')(e)) {
        e.preventDefault()
        return toggleEmphasize(editor)
      } else if (isHotkey('mod+q')(e)) {
        e.preventDefault()
        return toggleCode(editor)
      }

      return next()
    },

is-hotkey

Check whether a browser event matches a hotkey.

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis