Doubts about the keydown event

two input boxes, listen for the keydown event to one of the input boxes, and assign its value to the other box, but the value is always one bit less, so there is no problem with the keyup event

clipboard.png

<div class="test">
    <input class="test1" type="text" name="test1">
    <input class="test2" type="text" name="test2">
</div>
<script type="text/javascript">
    var test1 = document.getElementsByClassName("test1")[0];
    var test2 = document.getElementsByClassName("test2")[0];

    test1.addEventListener("keydown", function(e) {
        test2.value = e.target.value;
    })
</script>
Mar.09,2021
The

keydown event is triggered before the text is typed into the text box. If you output the text in the text box in the keydown event, you will get the text before the keyboard event is triggered. When the keyup event is triggered, the operation of all keyboard events has been completed, and you will get the text after the keyboard event has been triggered. The flow of events that occur in the input box are focus, keydown, input, keyup, change, and blur.
check out other people's articles and post their links Link 1 Link 2


you can try delaying the execution of
setTimeOut (function () {test2.value = e.target.value;}, 0)

until the next round of event cycles.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaf1df-222f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaf1df-222f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?