fix for firefox keypress event
This commit is contained in:
parent
45281c60a2
commit
fd448b4c15
1 changed files with 23 additions and 3 deletions
|
@ -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 a new issue