capturing f5 keypress event in javascript using window.event.keyCode in [removed] event is always 0 and not 116

后端 未结 7 848
南方客
南方客 2020-11-29 09:02

i am creating an MVC application.There was a neccessitity to make a variable in a session to null upon closing of the application (i.e. window/tab) but not upon refreshing t

相关标签:
7条回答
  • 2020-11-29 09:29

    You could just write it like this:

    $(document.body).on("keydown", this, function (event) {
        if (event.keyCode == 116) {
            alert('F5 pressed!');
        }
    });
    
    0 讨论(0)
提交回复
热议问题