Skip to content
Advertisement

Why I can’t add “keydown” event on td >p element?

I want to trigger some action when user press a key inside a p tag inside a td element, here is the HTML of a “td” on my table.

The problem is that when I add the keydown event to every paragraph element I don’t see any response. Here is how I did it.

JavaScript
JavaScript

I had some other “keydown” events on the “td” elements but when I removed them it still not working.

When I use the “click” event instead “keydown” I obtain the response that I expect.

I read here https://www.w3schools.com/Jsref/event_onkeydown.asp that keydown event is supported in “p” and table elements.

I need to obtain the p in which the text editing is happening for update server info so add the event on the table cell is not working for me.

I really appreciate any help with this, links to read or suggestions.

Advertisement

Answer

If you shift the contentEditable onto the paragraph tags it will work.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement