WebForm 中的键盘快捷键

发布于 2024-12-01 22:29:19 字数 244 浏览 4 评论 0原文

我正在为销售人员制作一个 asp.net、c#、webforms 网站。屏幕顶部有四个主要按钮,我将使用它们来实现许多功能。我想要做的是将这些按钮设置为键盘上的 F1F2F3F4 键。

这将如何运作?我可以在 IE7 中覆盖类似 F1 的功能吗?我该如何实施呢?焦点必须在 IE7 上吗?

感谢有关此主题的任何和所有信息。

I am making an asp.net, c#, webforms web site for sales clerks. I have four main buttons at the top of the screen that I will be using for a lot of functions. What I want to do is set those buttons to F1, F2, F3 and F4 keys on the keyboard.

How will this work? Can I override functions like F1 in IE7? How do I go about implementing this? Does focus have to be on IE7?

Any and all information on this topic is appreciated.

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

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

发布评论

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

评论(1

最佳男配角 2024-12-08 22:29:19

您必须使用 javascript 来完成此操作,但据我所知,这不可能允许您重载特定的浏览器键(这是一件好事)。您仍然可以使用它们,但无法禁用默认浏览器行为。我会重新评估您对键盘快捷键的选择,看看是否存在更好的解决方案。

javascript 事件 onkeypress 正是您正在寻找的。 这是一个使用普通 javscript 的可靠示例。您还可以查看 jQuery 的实现

更新
一个名为 Kibo 的新 JavaScript 库已发布。它是一个功能齐全的键盘快捷键处理程序,正是您所寻找的。

You'll have to do this with javascript, but there's no way that I'm aware of that will allow you to overload specific browser keys (this is a good thing). You'll still be able to use them, but there won't be a way to disable the default browser behavior. I'd re-evaluate your choice of keyboard shortcuts and see if a better solution exists.

The javascript event onkeypress is what you're looking for though. Here is a solid example using vanilla javscript. You can also look at jQuery's implementation.

Update
A new javascript library called Kibo has been released. It's a fully featured keyboard short-cut handler and would be exactly what you're looking for.

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