Shake element by keycode

I'm using the code bellow inside a module to save in the phonePlusServer_jsrow variable the keyCode returned by the keyboard. However, when I press a button on keyboard (e.g a letter), exit the module and come back it is as if the number had been pressed again. Anybody know how to improve this point? Thank you in advance!

HTML(sprintf("<div class=\"form-group shiny-input-container\" style = \"width:%s\">  
                                    <label for=\"%s\">%s</label>
                                    <input id=\"%s\" 
                                    type=\"text\" class=\"form-control\" placeholder=\"%s\" value=\"%s\" style = \"background-image:url(phone.png); background-size: 30px 30px; background-position: 
                                     0%% 50%%; background-repeat: no-repeat; padding: 0 0 0 35px;\"
                                    onkeydown=\"Shiny.setInputValue('%s_jsrow', [event.keyCode,event.timeStamp]);        
                                    return (event.keyCode >=48 && event.keyCode <= 57)
                                     || event.keyCode == 8||(event.keyCode >=37 && event.keyCode <= 40)||(event.keyCode >=33 && event.keyCode <= 34)||event.keyCode == 46
                                     ||event.keyCode == 45||event.keyCode == 9||event.keyCode == 13||event.keyCode == 32||(event.keyCode >=16 && event.keyCode <= 18)||event.keyCode == 189
                                     ||event.keyCode == 173||(event.keyCode >=112 && event.keyCode <= 123)||event.keyCode == 144||(event.keyCode >=96 && event.keyCode <= 105);\" required/>
                                     </div>",
                                     addWidth, ns("phonePlusServer"), addLabel, ns("phonePlusServer"), addPlaceholder, addValue, ns("phonePlusServer"))
                        )