Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom event listener option #122

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open

Conversation

acarl005
Copy link

@acarl005 acarl005 commented Jun 18, 2020

As discussed in issue #123, this PR add a new option to the CodeFlask constructor: customEventListeners.

customEventListeners is an object where the keys are the event names and the values are the callbacks for the event. This is an example of using this option to implement a hotkey like cmd+enter which doesn't cause a newline to get added to the content of the editor.

      flask = new CodeFlask(editor, {
        customEventListeners: {
          "keydown": e => {
            if (e.key == "Enter" && e.ctrlKey) {
              e.preventDefault()
              e.stopImmediatePropagation()
              // trigger hotkey
            }
          }
        }
      })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants