I'm using dynamic labels that need to detect when input goes into a text input.
I detect keydown events and I also detect paste events, for when the user pastes in text.
However, I still do not detect text that is dragged and dropped in.
I looked here and it looks like I should detect drop events.
Is this correct. Should I set an event listener for drop events? How can I make sure it is text that is dropped and not something else?
Here is how I do my keypresses and pastes
input_element.addEventListener("paste", function () {
label_element.style.opacity = 0;
}, false);
input_element.addEventListener("keypress", function () {
label_element.style.opacity = 0;
}, false);
How do I detect drops of text?
One guess:
input_element.addEventListener("drop", function () {
// verify it is text that is dropped
label_element.style.opacity = 0;
}, false);
Close:
input_element.addEventListener("dragdrop", function () {
// verify it is text that is dropped
label_element.style.opacity = 0;
}, false);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.