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

  • Home
  • SEARCH
  • 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 6539489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:51:54+00:00 2026-05-25T10:51:54+00:00

Is it possible to capture these shortcuts? Ctrl + N Ctrl + T Ctrl

  • 0

Is it possible to capture these shortcuts?

  • Ctrl+N
  • Ctrl+T
  • Ctrl+W

I tried this but it doesn’t work:

$(window).keydown(function(event) {
  console.log(event.keyCode);
  event.preventDefault();
});

When I press T it shows 84 in the console, but if I press Ctrl+T it shows nothing, and opens a new tab.

I would like to capture these shortcuts and prevent any browser action.

  • 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. Editorial Team
    Editorial Team
    2026-05-25T10:51:55+00:00Added an answer on May 25, 2026 at 10:51 am

    Capturing Ctrl keyboard events in Javascript

    Sample code:

    $(window).keydown(function(event) {
      if(event.ctrlKey && event.keyCode == 84) { 
        console.log("Hey! Ctrl+T event captured!");
        event.preventDefault(); 
      }
      if(event.ctrlKey && event.keyCode == 83) { 
        console.log("Hey! Ctrl+S event captured!");
        event.preventDefault(); 
      }
    });
    

    Firefox

    (6.0.1 tested)

    In Firefox both event listener works. If you press CtrlT or CtrlS keycombinations, you will get both message on the console, and the browser wont open a tab, nor ask for save.

    It is intresting that if you use alert instead of console.log the event.preventDefault() not works, and opens a new tab or asks for save. Maybe this bug needs to get fixed.


    Chrome3

    In Chrome 3 it works like in Firefox.


    Chrome4

    (tested)

    In Chrome4, certain control key combinations have been reserved for browser
    usage only and can no longer be intercepted by the client side JavaScript
    in the web page.
    These restrictions did not exist in Chrome3 and are inconsistent with both
    Firefox3/3.5 and IE7/8 (on Windows).

    In Chrome 4 it works similary to Firefox, except some keyboard combination:

    • CtrlN

    • CtrlShiftN

    • CtrlT

    • CtrlShiftT

    • CtrlW

    • CtrlShiftW

    These combinations cannot get captured by Javascript, but embed plugins can capture these. For example if you focus in a Youtube video and press CtrlT, the browser won’t open a new tab.


    IE7/8

    It works like in Firefox or Chrome3.


    IE9

    (tested)

    IE9 is a black sheep again, because it dosen’t allow javascript to capture any Ctrl? keyboard event. I tested with many keyboard combination (R,T,P,S,N,T) and neither worked. Also embed applications can’t capture the event. Tested with Youtube videos.


    Thanks to @Lime for the great link.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, this question with a difference... Is it possible to capture print output from
Is it possible to capture Python interpreter's output from a Python script? Is it
How would it be possible to capture the audio programmatically? I am implementing an
I was just wondering if it is possible to capture the output of a
Simply, is it possible to somehow capture the dimensions (specifically, width and height) of
Is it possible to take a screen capture of a particular area of a
Is it possible to skip a couple of characters in a capture group in
Does anyone know if it's possible to use regex capture within Apache's DirectoryMatch directive?
In some screen capture software when you press a key it's possible for the
Is it possible to run an external process from Perl, capture its stderr, stdout

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.