prototype: Don't translate "keypress" events into "keydown" events.

This commit is contained in:
Sam Stephenson 2007-10-16 03:36:58 +00:00
parent 8d3d6cdb04
commit bfd5353cbf
2 changed files with 13 additions and 9 deletions

View File

@ -1,5 +1,8 @@
*SVN*
* Don't translate "keypress" events into "keydown" events. [sam]
Note: "keypress" is broken in Safari <= 2.x, but Event#stop has no effect on "keydown" events.
* Changed Element#makeClipping to remember the original overflow value, even if it's a non-inline style. [Andrew Dupont]
* Cross-browser Event#isLeftClick with the addition of is(Middle|Right)Click. Closes #7520. [Christophe Porteneuve, Richard Quadling, Mislav Marohnić]

View File

@ -30,23 +30,24 @@ Object.extend(Event, {
});
Event.Methods = (function() {
// mouse button detection is terribly inconsistent
if (Prototype.Browser.IE) {
var isButton = function(event, code) {
return event.button == ({ 0:1, 1:4, 2:2 })[code];
};
function isButton(event, code) {
return event.button == ({ 0: 1, 1: 4, 2: 2 })[code];
}
} else if (Prototype.Browser.WebKit) {
var isButton = function(event, code) {
function isButton(event, code) {
switch (code) {
case 0: return event.which == 1 && !event.metaKey;
case 1: return event.which == 1 && event.metaKey;
default: return false;
}
};
}
} else {
var isButton = function(event, code) {
function isButton(event, code) {
return event.which ? (event.which === code + 1) : (event.button === code);
};
}
}
return {
@ -129,7 +130,7 @@ Object.extend(Event, (function() {
function getDOMEventName(eventName) {
if (eventName && eventName.match(/:/)) return "dataavailable";
return { keypress: "keydown" }[eventName] || eventName;
return eventName;
}
function getCacheForID(id) {