3
Well, as the title indicates, I’d like to know how to lock the key F5 javascript.
3
Well, as the title indicates, I’d like to know how to lock the key F5 javascript.
9
If your intention is to prevent the user from doing refresh in the browser this will not be possible. It is the right of the user to do this.
If you want to use the key F5 for another feature then the code of that key is 116
, You only need to have an event headphone keydown
.
window.addEventListener('keydown', function (e) {
var code = e.which || e.keyCode;
if (code == 116) e.preventDefault();
else return true;
// fazer algo aqui para quando a tecla F5 for premida
});
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
It worked properly, thank you!
– Gonçalo
Keep in mind that this will only intercept the F5 key... Ctrl+R, Command+R and Menu>Refresh will still work...
– fernandosavio