Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS This code is not working properly in chrome browser…

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #45026
    Robin
    Participant

    $(document).keypress(function (e) {
    if( e.ctrlKey && (e.which == 17 || e.which==48) ) {

    alert(“crtl+0”);
    }

    else if (e.ctrlKey && (e.which == 17 || e.which==61) ) {

    alert(“crtl+plus”);
    }

    else if (e.ctrlKey && (e.which == 17 || e.which==43) ) {

    alert(“ctrl+plus2”);
    }

    else if (e.ctrlKey && (e.which == 17 || e.which==45) ) {

    alert(“ctrl+minus”);
    }

    });

    #136297
    thomasR
    Member

    What are you trying to do? Detect browser zoom? Be aware that zoom can be changed in the menu in which case the event won’t be triggered.

    There are 3 key events: keydown, keypress and keyup. `keypress` is special because it is only triggered for keys and key combinations which can insert characters (I’m simplifying of course) and sets `e.which` to the ascii code of the pressed letter instead of the key code. I think that’s becuase it’s main use is to capture user input.

    `keyup` is probably the better option here.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘CSS’ is closed to new topics and replies.