$(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 - |
Domanda
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?
Soluzione
Altri suggerimenti
using document.keyup
check out this fiddle, try clicking ctrl + i
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow