I want Alt+O short keys to browse a file in my web page. "Keydown" event can handle this issue perfectly in chrome however in Firefox nothing happens unless I do a click in page. Is there any solution to my problem?
$(document).ready(function(){
$("body").keydown(function(e){
var keyCode = (e.which) ? e.which : window.e.keyCode;
if(e.altKey)
if(keyCode == 79){ //Alt+O = openFile
e.preventDefault();
$("#xmlFile:hidden").trigger('click')
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="file" id="xmlFile" style="display: none;" >