Skip to content

Option to add custom event listeners to the CodeFlask textarea #123

Open
@acarl005

Description

@acarl005

Hello, I really like this library for it's small size. I was hoping to be able to add hotkeys to my editor, e.g. ctrl+enter to "execute" code. I tried to implement this by adding a "keydown" listener on the textarea generated by codeflask, but I was unable to prevent a newline from being inserted to the code due to the default behavior of the enter key. I tried, e.preventDefault(), but that was insufficient. Apparently I need to stop the "keydown" listener that codeflask added in order to prevent that. This is possible using e.stopImmediatePropagation(), but only if I call that method from an event handler that triggers before the other one. Since event handlers are triggered in the order they are added, this is impractical for the user. It would be nice if the CodeFlask constructor provided a way for users to add custom event handlers before the ones added by the library. I propose an implementation in my pull request #122 which allowed me to implement my hotkey. Please let me know if this is a welcome feature. I'm happy to help design this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions