{"id":247,"date":"2009-09-28T22:55:33","date_gmt":"2009-09-28T17:25:33","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=247"},"modified":"2022-01-13T16:41:28","modified_gmt":"2022-01-13T11:11:28","slug":"add-hotkeys-to-web-application","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/add-hotkeys-to-web-application\/","title":{"rendered":"Add hotkeys to the web application"},"content":{"rendered":"<p>Let us have a look at the simple javascript code, that can be used to add hotkeys to our web application. I tried using jquery hotkeys plugin and two more plugins, but they didn&#8217;t work for me.<\/p>\n<p>So I ended up handling the keydown event of my own.<\/p>\n<blockquote>\n<div class=\"wp_syntax\">\n<div class=\"code\">\n<pre class=\"groovy\">var isAlt = false;\r\ndocument.onkeyup = function(e) {\r\n    if (e.which == 18) \/\/18 is the keycode for 'Alt'\r\n\tisAlt = false;\r\n}\r\ndocument.onkeydown = function(e) {\r\n    if (e.which == 18)\r\n\t isAlt = true;\r\n    else if (e.which == 69 &amp;&amp; isAlt == true) { \/\/69 is the keycode for 'e'\r\n        function1(); \t \/\/ executed when alt+e is pressed\r\n        return false;\r\n    } else if (e.which == 71 &amp;&amp; isAlt == true) {\r\n        function2(); \t \/\/ executed when alt+g is pressed\r\n        return false;\r\n    }\r\n    ...\r\n}<\/pre>\n<\/div>\n<\/div>\n<\/blockquote>\n<p>Hope this helped.<\/p>\n<p>Cheers!<br \/>\n~~Amit Jain~~<br \/>\namit@intelligrape.com<br \/>\nIntelliGrape Softwares<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let us have a look at the simple javascript code, that can be used to add hotkeys to our web application. I tried using jquery hotkeys plugin and two more plugins, but they didn&#8217;t work for me. So I ended up handling the keydown event of my own. var isAlt = false; document.onkeyup = function(e) [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3},"categories":[1],"tags":[131,55,132],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/247"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=247"}],"version-history":[{"count":1,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/247\/revisions"}],"predecessor-version":[{"id":54651,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/247\/revisions\/54651"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}