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

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.

  • 0 0 Answers
  • 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

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

I have a web page where i have an ASP.NET file upload control to
I have a web page where I'd like to remap Ctrl+N to a different
I have a web page where i have 2 forms when i click the
I have a web page where I want to switch the background image of
I'm have a web page where I have a div within which there is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.