I have a website that won't accept values inserted into INPUT
element's value
directly via JS. The only way it works if I try to imitate sending space
key via jQuery (which is bundled with web-site) after changing the value itself:
elem.value = 'Im so tried of meme frameworks';
elem.focus();
press = jQuery.Event("keypress");
press.which = 32;
$(elem).trigger(press);
While this works, I want to avoid injecting code to use on-site jQuery or bundle jQuery with extension (it is 20-30 times larger than whole extension). I sought alternatives, but to my surprise NONE of them work -- or rather produce the same result as jQuery's one -- in in Chrome 114 in 2023:
Old KeyboardEvent Dispatch
:
Keydown Simulation in Chrome fires normally but not the correct key
Simulating keyboard press in a way that isn't deprecated?
Is it possible to simulate key press events programmatically?
Just Event
:
Trigger a keypress/keydown/keyup event in JS/jQuery?
And so on. Even seems to be firing but space
"press" never ever registered or felt by input field in any way.
What magic does jQuery pull off that we can't do?