如何在 Javascript/Php 中创建全局键盘快捷键?

发布于 2024-11-29 07:22:54 字数 197 浏览 2 评论 0原文

我正在尝试以 ajax+php 的方式创建一种管理应用程序。我对 JS 和 PHP 编码有点陌生,所以我认为这将是一个很好的测试,它是那些可能没有用的东西之一,你编写它来搞砸。

由于该应用程序要在打开另一个窗口的情况下使用,因此我需要创建一个键盘快捷键,无论哪个窗口处于焦点状态,该快捷键都可以使用。有什么方法可以在 Php/Javascript 中做到这一点吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦中楼上月下 2024-12-06 07:22:54

PHP 是一种服务器端语言,因此它根本无法做这样的事情。它无法接收点击、按键等用户事件。Javascript

在客户端的浏览器中运行,可以处理用户事件,但只能处理源自当前窗口的事件。

抱歉,您需要找到不同的解决方案。我敢打赌 http://www.superuser.com 上有很多很好的问题和答案,可以帮助您你

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

吐个泡泡 2024-12-06 07:22:54

这在基于浏览器的 Web 应用程序中根本不可能实现。仅当浏览器窗口聚焦时,甚至当您的特定选项卡聚焦时,您才能对击键做出反应。这是网络浏览器的安全沙箱功能。想想如果一个网站被最小化并将您的所有击键记录到您正在输入的所有其他窗口中会发生什么...银行密码...等等...抱歉!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文