I'm writing a Chrome extension and I'm trying to programmatically trigger a keypress event on the textarea
element where you type in Facebook chat.
If I look at the element in the inspector, I can see that it has an onkeydown
handler set:
onkeydown="run_with(this, ["legacy:control-textarea"], function() {TextAreaControl.getInstance(this)});"
--but I can't trigger it. While trying to figure out why I can't trigger it, I found that when I select the element using one of the classes on it and type document.querySelector('._552m').onkeydown
in the console, it comes up null
. Likewise, using getAttribute
on it for onkeydown
comes up null
.
What am I missing here? How can I get at this event handler? Why can I see it set on the element in the inspector and yet not access it programmatically in the usual way? Is React pulling some weird magic here?
Edit: document.querySelector('._552m').attributes
shows the onkeydown
attribute listed....wtf...