user890704
user890704

Reputation:

How to create global keyboard shortcuts in Javascript/Php?

I'm attempting to create a sort of management application in an ajax+php sort of fashion. I'm sort of new to coding JS and PHP, so I figured that this would be a nice test, it's one of those things that may not have a use and you code it to screw around.

Since the application is to be used with another window open, I need to create a keyboard shortcut that will work regardless of which window is in focus. Is there any way to do that in Php/Javascript?

Upvotes: 1

Views: 927

Answers (2)

Jason Clawson
Jason Clawson

Reputation: 1027

This is simply not possible in browser based web applications. You can only react to keystrokes when the browser window is focused, and even then, when your specific tab is focused. This is a security sandbox feature of web browsers. Think about what would happen if a website was minimized and logged all your keystrokes to all other windows you were typing in... bank passwords... etc.... Sorry!

Upvotes: 0

nickf
nickf

Reputation: 546055

PHP is a server-side language, so it won't be able to anything like this at all. It can't receive user events like clicks, keypresses, etc.

Javascript runs in the browser on the client side and can handle user events, but only ones which originate from the current window.

You'd need to find a different solution, sorry. I would bet that there's a lot of good questions and answers on http://www.superuser.com which could help you

Upvotes: 1

Related Questions