Closed
Bug 227228
Opened 21 years ago
Closed 21 years ago
can not preventDefault() on CTRL+D
Categories
(SeaMonkey :: Bookmarks & History, defect)
SeaMonkey
Bookmarks & History
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: goobsoft, Assigned: p_ch)
Details
(Keywords: helpwanted)
Attachments
(1 file)
848 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624
I have a site where there are many shortcuts to speed up UI. One of my
shortcuts is CTRL+D for deselect all. Everytime a user uses this it will
bookmark the page. See the example below:
<HTML>
<HEAD>
<TITLE>bad</TITLE>
</HEAD>
<BODY>
If you press CTRL+D you will get an alert indicating that the correct
function is running, but you will have a bookmark despite the calls to
event.preventDefault() and event.stopPropagation().
</BODY>
<SCRIPT>
function KeydownListener() {
this.handleEvent = function(event) {
if (event.DOM_VK_D == event.keyCode) {
if (event.ctrlKey) {
alert("stopping");
event.preventDefault();
event.stopPropagation();
}
}
}
}
var useCapture = true;
var object = document;
//var object = window;
object.addEventListener("keydown", new KeydownListener(), useCapture);
object.addEventListener("keypress", new KeydownListener(), useCapture);
object.addEventListener("keyup", new KeydownListener(), useCapture);
</SCRIPT>
</HTML>
Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Actual Results:
the page is bookmarked
Expected Results:
the page should not be bookmarked
Reporter | ||
Comment 1•21 years ago
|
||
![]() |
||
Comment 2•21 years ago
|
||
Bookmarks bug -- the bookmark-adding code should not trigger if the event's
default action has been prevented...
Assignee: events → p_ch
Component: DOM: Events → Bookmarks
![]() |
||
Updated•21 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: helpwanted
OS: Windows 2000 → All
Hardware: PC → All
Comment 3•21 years ago
|
||
The add bookmark triggers on the keypress event with a charCode of DOM_VK_D.
If you prevent that event then the bookmark is not added.
Mozilla does not set the keyCode on a character keypress event.
Nor does preventing the keydown event prevent the keypress event.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
Reporter | ||
Comment 4•21 years ago
|
||
You are right. The last trick is to change the charCode to lowercase.
if (event.DOM_VK_D == (event.charCode & 0xDF)) {
Updated•20 years ago
|
Product: Browser → Seamonkey
You need to log in
before you can comment on or make changes to this bug.
Description
•