How can I raise the onkeydown event in the html table in Firefox?

I want to capture keystrokes on table cells. I have the following code that works on IE but not on Firefox / Chrome.

<table id="testing" onkeydown="alert('testing')"><br />
    <tr><td>testing</td></tr>` <br />
    </table>
<br />

Any suggestion?

+5
source share
2 answers

http://www.w3schools.com/jsref/jsref_onkeydown.asp indicates that most tags support onkeydown.

You need to set the property tabindex(for example tabindex="1") to some value so that it can identify that this table is selected by the keyboard. This allows you to trigger a keyboard event. The following will work in firefox:

<table id="testing" onkeydown="alert('testing')" tabindex="0"><br />
<tr><td>testing</td></tr><br />
</table> 
+9
source

, -, Firefox Chrome , . .

W3C , onkeydown, Firefox/Chrome, Firefox -. , ( , , )

, ?

  • , , <input> , .
  • , , , ,
+2

All Articles