I wish to interrupt on mouseenter
/ on mouseleave
events when TAB keypresses occur via on keyup
.
For example, when doMouseEnter is interrupted via pressing TAB, I want to eliminate the inherent highlighting that doMouseEnter
does and then let doStuff2()
do its thing.
Any ideas that could start me in the right direction?
The former occur with:
$(document).ready(function () {
$("#menubar > li").on({
mouseenter: function(evt) {
doMouseEnter($(this), evt);
},
mouseleave: function(evt) {
doMouseLeave($(this), evt);
}
}); // on
});
The latter occur with:
$(document).ready(function() {
$(document).keyup(function (evt) {
var code = evt.keyCode || evt.which;
if (evt.shiftKey && code === 9) {
doStuff1(evt);
}
else if (code === 9) {
doStuff2(evt);
}
}); // $(document).keyup(function (evt) {
}); // $(document).ready(function() {
EDIT :
Let me pause my request ... I found some leads elsewhere on your Site that address interrupting Events ... thanks for understanding.
as "tab" button has default duty in almost every window, I think you should consider "shift", "alt", "control" buttons for this issue. enter code here
$(document).ready(function(){ $(document).focus(); var keyPressed = false; var mouseovered = false; $("#btn").mouseover(function(e){ doStuff(); mouseovered = true; }); $("#btn").mouseout(function(){ doStuff(); mouseovered = false; }); $(document).keydown(function(e){ doStuff(); if (e.ctrlKey) { keyPressed = true; } else keyPressed = false; }); $(document).keyup(function(e){ if (keyPressed) { keyPressed = false; } doStuff(); }); function doStuff() { if(mouseovered && keyPressed) $("#center").css({"color": "#000"}); else $("#center").css({"color": "#fff"}); } });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.