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 6787129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:19:43+00:00 2026-05-26T17:19:43+00:00

$(document).keydown(function (e) { if (e.keyCode == 83 && (navigator.platform.match(Mac) ? e.metaKey : e.ctrlKey)) {

  • 0
$(document).keydown(function (e) {
    if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
        function_which_does_a_lot_including_ajax_calls();
        return false;
    }
});

I’m trying to call a method on control+S, and, the call to function_which_does_a_lot_including_ajax_calls() stops the code from reaching the “return false” in time, which means that the browser prompts the default “Do you want to save this website” window.

If I change it to simply:

$(document).keydown(function (e) {
    if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
        // function_which_does_a_lot_including_ajax_calls();
        return false;
    }
});

… the return false is triggered, and nothing happens (no default prompt).

Is there a way I can do a lot of stuff, but still return false so that the browser does not do its default behavior? Thanks!

  • 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-26T17:19:44+00:00Added an answer on May 26, 2026 at 5:19 pm

    I’m not sure I understand the behaviour you described but you can try something like:

    $(document).keydown(function (e) {
        if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
            setTimeout(function_which_does_a_lot_including_ajax_calls, 100);
            return false;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 keydown handlers: $(document).bind('keydown', function(e) { if (e.keyCode == 75) { //
$(document).keydown(function (event) { if(event.keyCode==38 || event.keyCode==40) { var row; if(event.keyCode==40) row=$(row_selected).next(); if(event.keyCode==38) row=$(row_selected).prev(); if(row.length==0)
$(document).ready(function() { var test_func=function(ev) { alert(ev.keyCode); }; .... $(document).keydown(test_func(ev)); }); I wanna do the
$(#right).click(function(){ $(.block).animate({left: +=500px}, slow); }); $(#left).click(function(){ $(.block).animate({left: -=50px}, slow); }); //Control $(document).keydown(function(e){ if (e.keyCode
document.getElementById('container').addEventListener('copy',beforecopy,false ); In Chrome / Safari, the above will run the "beforecopy" function when
function observeingKeys() { console.log('watching keys now!'); $(document).observe('keypress', function(event){ switch (event.keyCode) { case Event.KEY_UP: console.log('Up');
I've got this Prototype code to detect Enter pressing in textarea. document.observe('keydown', function(e, el)
I'm trying to mimic the Google suggestions list with this: function el(tid) { return
document.observe('click', function(e, el) { if (e.target != Element.descendantOf('calendar')) { $('calendar').fade(); } }); I am
$(document).ready(function() { $(span.link).mouseover(function(e){ $(this.children).css(display,inline); }); }); I'm not a javascript expert, but I've cobbled

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.