robthewildman Posted May 31, 2020 Share Posted May 31, 2020 I'm programming in classic asp / JavaScript. Okay, I have a screen full of *.mdb Records. Each record is designated by a radio button. I click a record button and then click Another radio button to tell The computer what to do with it, and then click submit. Instead of all that, I would like to just click that record and then press a key, like F6 for edit, F4 for move, F10 for delete, Etc. At the present time all I have to do is just press enter to activate a function that is default, but that's only one function. Just point me in the right direction and I'll figure it out. Link to comment Share on other sites More sharing options...
dsonesuk Posted May 31, 2020 Share Posted May 31, 2020 Detect which key is pressed https://www.w3schools.com/jsref/event_key_keycode.asp Link to comment Share on other sites More sharing options...
ishan_shah Posted June 1, 2020 Share Posted June 1, 2020 You can use keyevents for that for example:<!DOCTYPE ht l<!DOCTYPE html> <html> <body> <h3>Trigger Button Click on Enter</h3> <p>Press the "Enter" key inside the input field to trigger the button.</p> <input id="myInput" value="Some text.."> <button id="myBtn" onclick="javascript:alert('Hello World!')">Button</button> <script> var input = document.getElementById("myInput"); input.addEventListener("keyup", function(event) { if (event.keyCode === 13) { event.preventDefault(); document.getElementById("myBtn").click(); } }); </script> <!DOCTYPE html> <html> <body> <h3>Trigger Button Click on Enter</h3> <p>Press the "Enter" key inside the input field to trigger the button.</p> <input id="myInput" value="Some text.."> <button id="myBtn" onclick="javascript:alert('Hello World!')">Button</button> <script> var input = document.getElementById("myInput"); input.addEventListener("keyup", function(event) { if (event.keyCode === 13) { event.preventDefault(); document.getElementById("myBtn").click(); } }); </script> </body> </html> Link to comment Share on other sites More sharing options...
dsonesuk Posted June 1, 2020 Share Posted June 1, 2020 Ohh he got so excited that he copied himself. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now