1

I want to automate keyboard events actions like Ctrl+F or Ctrl+s or Alt+Shift down etc. using Javascript. How to do it? Please help.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
lohith
  • 11
  • 3
  • Checkout this informative thread: http://stackoverflow.com/questions/596481/simulate-javascript-key-events – David R Aug 02 '16 at 08:14
  • 1
    What do you _really_ want to do? If the idea is to force browser shortcuts, then -- thankfully -- you cannot do that. – Arnauld Aug 02 '16 at 08:14
  • http://stackoverflow.com/questions/93695/best-cross-browser-method-to-capture-ctrls-with-jquery You can prevent event and call what you want , but you cant programmability call . This is "OnUserRequest" action , can be avoid only with user act . – Nikola Lukic Aug 02 '16 at 08:37
  • @Arnauld , i want to invoke keyboard events like "ctrl f", on clicking "ctrl f" browser invokes find feature. I want to automate this process. – lohith Aug 02 '16 at 08:48
  • @lohith For the 'find' feature, you may be able to do it on some browsers: [Use Browser Search (Ctrl+F) through a button in website?](http://stackoverflow.com/questions/8080217/use-browser-search-ctrlf-through-a-button-in-website) – Arnauld Aug 02 '16 at 08:53
  • @Arnauld i am trying to automate using casperjs. will i be able to automate keyboard events programatically..? . I have no idea how to achieve this. – lohith Aug 02 '16 at 09:17
  • @NikolaLukic, can't i mimic user actions like ctrl a, ctrl s – lohith Aug 02 '16 at 09:24
  • maybe this is what you are looking for: http://stackoverflow.com/questions/596481/simulate-javascript-key-events – Jakubee Aug 02 '16 at 10:29
  • @Jakubee Why would you post the exact same link as in the very first comment. – Artjom B. Aug 02 '16 at 17:33
  • @lohith Can you give an example website where we can test our implementation for this? – Artjom B. Aug 02 '16 at 17:34
  • To clarify: you're expecting the web page itself to handle those shortcuts and not the usual browser stuff which PhantomJS wouldn't provide, right? – Artjom B. Aug 02 '16 at 17:36

0 Answers0