In this tutorial I will show you how to replace button click event with keyboard shortcuts using JQuery. Previously, I used button click event I called the JavaScript function for generating the sitemap. Instead of the button event. Here, I m going to implement keyboard shortcuts.
This is asp.net MVC project. I have already registered jQuery in Layout page.
I have written code for keyboard event. CTRL+ G When these key is pressed I going
to call GenerateSitemap() function. The keycode 71 is for Letter 'G'.
Here, You can find the list of keycode value for the keyboard press.
Link:http://gcctech.org/csc/javascript/javascript_keycodes.htm
jQuery Code:
<script type="text/javascript">$(document).keydown(function (e) {if (e.ctrlKey && e.keyCode == 77) {GenerateSubmitURLs();}});function GenerateSubmitURLs() {//Code here..}</script>
VIDEO TUTORIAL JQURERY KEYBOARD EVENT:
This video demonstrates how I Implementing keyboard shortcuts using jQuery.
Post your comments / questions
Recent Article
- How to get domain name information from a Domain using Python
- ModulenotFoundError: no module named 'debug_toolbar' -SOLUTION
- How to create superuser in django project hosted in cPanel without terminal
- CSS & images not loading in django admin | cpanel without terminal
- Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
- How to sell domain name on Godaddy (2023)
- TemplateSyntaxError at / Could not parse the remainder: ' + 1' from 'forloop.counter0 + 1'
- urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0
Related Article