Giter Club home page Giter Club logo

Comments (5)

zenoamaro avatar zenoamaro commented on May 18, 2024 1

There is a note in the README that explains that why you have to bind to onKeyUp to receive events from keys like enter, backspace or delete. Please try this and let me know.

from react-quill.

zenoamaro avatar zenoamaro commented on May 18, 2024

You can bind onKeyDown or onKeyUp on the element containing the editor and you'll receive an event as usual. You can wrap the editor into another component, or build a custom component using the mixin.

I want to allow a few more events on the editor, such as keypress events, but I want to hear what they would be used for before. Do you have a specific use-case?

from react-quill.

hackingbeauty avatar hackingbeauty commented on May 18, 2024

The methods onKeyDown/onKeyUp do not listen for the "enter" key button press (but they do for other keys). I just tested this by binding them to the element containing the editor.

However, I did find an alternate solution. Via the onChange method on the ReactQuill component, I can query for the "enter" key button using this statement which yields a value of 10:

delta.ops[delta.ops.length -1].insert.charCodeAt(0);

My use case is very specific. I'm allowing users to use the text editor while watching videos. When pressing letter keys the video automatically pauses. When pressing the "enter" key, the video resumes playing.

from react-quill.

zenoamaro avatar zenoamaro commented on May 18, 2024

It seems there is an issue where Quill prevents keydown events for enter, backspace and delete from bubbling up. But you can still receive them when using onKeyUp.

I've just pushed some "official" hooks for keypress events so that you won't have to hook them on a separate container. See also [the note about onKeyDown] in the README, which should explain the situation.

Let me know if this works for you!

from react-quill.

hackingbeauty avatar hackingbeauty commented on May 18, 2024

I just downloaded version 0.2.2, and onKeyPress does not work for me. Neither does onKeyDown.

from react-quill.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.