mirror of https://github.com/zulip/zulip.git
Standardize on 'e', not 'event', within hotkey.js.
Mixing these two in this file is bound to lead to a world of hurt (and has, historically). At some point I'd like to do this across the entire codebase. (imported from commit 9ff029597587f9c37a0bd9f32c25a769aa1a7a20)
This commit is contained in:
parent
cdb31303fc
commit
d7f146ed4f
|
@ -156,29 +156,29 @@ exports.set_compose = function () {
|
|||
so we bail in .keydown if the event is a letter or number and
|
||||
instead just let keypress go for it. */
|
||||
|
||||
function down_or_press(event) {
|
||||
var result = current_key_handler(event);
|
||||
function down_or_press(e) {
|
||||
var result = current_key_handler(e);
|
||||
if (result) {
|
||||
current_key_handler = result;
|
||||
event.preventDefault();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).keydown(function (event) {
|
||||
$(document).keydown(function (e) {
|
||||
// Restrict to non-alphanumeric keys
|
||||
if (48 > event.which || 90 < event.which)
|
||||
down_or_press(event);
|
||||
if (48 > e.which || 90 < e.which)
|
||||
down_or_press(e);
|
||||
});
|
||||
|
||||
$(document).keypress(function (event) {
|
||||
$(document).keypress(function (e) {
|
||||
// What exactly triggers .keypress may vary by browser.
|
||||
// Welcome to compatability hell.
|
||||
//
|
||||
// In particular, when you press tab in Firefox, it fires a
|
||||
// keypress event with keycode 0 after processing the original
|
||||
// event.
|
||||
if (event.which !== 0 && event.charCode !== 0)
|
||||
down_or_press(event);
|
||||
if (e.which !== 0 && e.charCode !== 0)
|
||||
down_or_press(e);
|
||||
});
|
||||
|
||||
return exports;
|
||||
|
|
Loading…
Reference in New Issue