$(document).on("keydown", function(e){
e = e || window.event;
var keyCode = event.keyCode; // code of the key pressed
if(e.ctrlKey){ // if control key is pressed
if(keyCode == 13){ // if current key is "enter" key
$("input[type='file']").trigger("click"); // trigger click event
}
}
});
js - set hotkeys on upload files
-
24-06-2023 - |
Question
For example, I have an input tag like:
<input type="file" id="upload" multiple="true">
Is this possible to choose files by setting a hotkey instead of clicking on input element?
La solution
Autres conseils
using document.keyup
check out this fiddle, try clicking ctrl + i
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow