Skip to content

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.

2 participants