网站中的快捷键或热键 [英] Shortcut key or hot key in website
本文介绍了网站中的快捷键或热键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为我的网格添加快捷键。如何分配新的Alt + a。
什么是Alt + a的ascii键
谢谢
Basit
我尝试过:
我尝试将功能键F1作为112 ascii代码。
解决方案
ALT + A没有ASCII码(但是keyCode是18),只有A有一个ASCII代码,您将仅针对该代码进行测试。但是,您还将测试用户是否也按下了ALT键。
我建议将事件处理程序附加到HTML文档(或以非常推荐的方式,附加到body元素),然后使用JavaScript处理它。所以,为此,试试这个:
( document )。ready( function (){
(' body')。keydown( function (){
if ( window .event.altKey == true &&& class =code-sdkkeyword> window .event.keyCode == 65 ){
document .getElementById( landing)。innerText = Alt + A已按下。;
} else {
document .getElementById( landing)。innerText = Alt +未组合。;
}
});
});
这也可以在编辑小提琴中进行测试 - JSFiddle [ ^ ]。您现在还可以根据需要为键添加更多组合。
更多信息: KeyboardEvent Value(keyCodes,metaKey等)| CSS-Tricks [ ^ ]
Hi,
I want to add shortcut key for my grid. How to assign for new Alt+a.
What is the ascii key for Alt+a
Thanks
Basit
What I have tried:
I tried function key F1 as 112 ascii code.
解决方案
ALT + A has no ASCII code (but the keyCode is 18), only A has an ASCII code and you will be testing against that one only. However, you will also be testing if the ALT key is also pressed by the user.
I would recommend attaching an event handler to the HTML document (or in a much recommended way, to the body element) and then handle it using JavaScript. So, for that just try this:
(document).ready(function () {
('body').keydown(function () { if(window.event.altKey == true && window.event.keyCode == 65) { document.getElementById("landing").innerText = "Alt + A pressed."; } else { document.getElementById("landing").innerText = "Alt + A combination not made."; } }); });
This can also be tested at, Edit fiddle - JSFiddle[^]. You can now also add more combinations for the keys as per they are needed.
For more: KeyboardEvent Value (keyCodes, metaKey, etc) | CSS-Tricks[^]
这篇关于网站中的快捷键或热键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文