automatically press keyboard with jQuery?

前端 未结 6 1928
臣服心动
臣服心动 2021-01-19 04:06

Is it possible with jQuery to automatically simulate a press on a keyboard, f.ex. inside an html input field?

As explanation: If I press the a inside an

6条回答
  •  走了就别回头了
    2021-01-19 04:31

    You can try something like.

    $("inputSelector").trigger($.Event("keypress", { keyCode: 97 }));
    

    Pass the keycode of whatever key you want.

提交回复
热议问题