Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 183163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:04:01+00:00 2026-05-11T15:04:01+00:00

I have a web page where I’d like to remap Ctrl+N to a different

  • 0

I have a web page where I’d like to remap Ctrl+N to a different behavior. I followed YUI’s example of register Key Listeners and my function is called but Firefox still creates a new browser window. Things seem to work fine on IE7. How do I stop the new window from showing up?

Example:

var kl2 = new YAHOO.util.KeyListener(document, { ctrl:true, keys:78 },              {fn:function(event) {                      YAHOO.util.Event.stopEvent(event); // Doesn't help                      alert('Click');}}); kl2.enable(); 

It is possible to remove default behavior. Google Docs overrides Ctrl+S to save your document instead of bringing up Firefox’s save dialog. I tried the example above with Ctrl+S but Firefox’s save dialog still pops up. Since Google can stop the save dialog from coming up I’m sure there’s a way to prevent most default keyboard shortcuts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:04:02+00:00Added an answer on May 11, 2026 at 3:04 pm

    The trick is the ‘fn’ function is whack.

    Experimentally, you can see that the function type for fn takes two parameters. The first param actually contains the TYPE of event. The second one contains… and this is screwy: an array containing the codepoint at index 0 and the actual event object at index 1.

    So changing your code around a bit, it should look like this:

    function callback(type, args) {     var event = args[1]; // the actual event object     alert('Click');      // like stopEvent, but the event still propogates to other YUI handlers     YAHOO.util.Event.preventDefault(event); } var kl2 = new YAHOO.util.KeyListener(document, { ctrl:true, keys:78 }, {fn:callback}); kl2.enable(); 

    Also, for the love of lisp, don’t use raw code points in your code. Use ‘N’.charCodeAt(0) instead of ’78’. Or wrap it up as a function

    function ord(char) {     return char.charCodeAt(0); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web-page that looks like this (simplified example) <table id=events_results_table> <thead> <tr>
I have web page that looks like this: Image on the left - text
I have a web page in which people go to register for my site.
i have web page it has a page header content like main menu,logo and
I have a web page, using jQuery and javaScript, and I would like to
So, I have web page that uses javascript to let a user select different
I have web page in PHP which displays all records in a table. I
I have web page which is passing a querystring parameter to page 2: <a
new on rails and using windows for now,, i have web page that user
I have web forms page that has 2 controls. A gridview and an associated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.