Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
-4
rated 0 times [  3] [ 7]  / answers: 1 / hits: 17462  / 11 Years ago, tue, july 16, 2013, 12:00:00

I have this code, I would need programmatically overridde or remove onkeydown from document (for example using a simple condition)



document.onkeydown = function (f) {
myMethod();
};


Any idea how to do it?


More From » jquery

 Answers
26
document.onkeydown = null


You could use jquery to do your event handeling for you, the method you use is less commonly used and doesn't allow multiple subscribers.



Look at the documentation here:



http://api.jquery.com/on/



example:



$(document).on(keydown, function(){
doStuff();
})
// unsubscribe all handlers
$(document).off(keydown);

[#76970] Monday, July 15, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isham

Total Points: 69
Total Questions: 86
Total Answers: 86

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;