fix for firefox keypress event
This commit is contained in:
parent
e611ec8380
commit
2b9893c514
|
@ -454,10 +454,30 @@ requires
|
|||
|
||||
$(function() {
|
||||
// fixme: how to do this better?
|
||||
if ($.browser.safari) {
|
||||
$document.keydown(keypress);
|
||||
} else {
|
||||
// in firefox, keypress doesn't fire for up/down
|
||||
// if the cursor is at the start/end of an input element
|
||||
if ($.browser.mozilla) {
|
||||
$document.keypress(keypress);
|
||||
$document.keydown(function(event) {
|
||||
var $element = $("input:focus");
|
||||
if ($element.length) {
|
||||
console.log("@", $element[0].selectionStart, $element[0].selectionEnd)
|
||||
if (
|
||||
(
|
||||
keyNames[event.keyCode] == "up" &&
|
||||
$element[0].selectionStart + $element[0].selectionEnd == 0
|
||||
) || (
|
||||
keyNames[event.keyCode] == "down" &&
|
||||
$element[0].selectionStart == $element.val().length &&
|
||||
$element[0].selectionEnd == $element.val().length
|
||||
)
|
||||
) {
|
||||
keypress(event);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$document.keydown(keypress);
|
||||
}
|
||||
});
|
||||
function keypress(event) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user