为指定的元素返回一个处理程序对象,以添加快捷键。
eventer.shortcuts(elm)
Example: 快捷键 CTRL+ALT+SHIFT+X 。
<!DOCTYPE html> <html> <head> <style> </style> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script> <script> require.config({ baseUrl: "./", packages: [ { name: "skylark", location: "../../../src/skylark" }, ] }); </script> </head> <body> <p></p> <script> require(["skylark/finder", "skylark/eventer"], function(finder, eventer) { eventer.shortcuts(document.body).add("CTRL+ALT+SHIFT+X", function(e) { var p = finder.find("p"); p.innerHTML = e.code || e.keyCode; }); }); </script> </body> </html>