1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

surpress defaul cntrl codes

Discussion in 'JavaScript' started by tanyania, Jun 26, 2011.

  1. #1
    Hi everyone

    does any one know how to surpress the browser default cntrl codes like cntrl S, cntrl A

    I have written some cntrl functions in jquery that perform tasks but once complete, the default cntrl code functionality always kicks in.

    any help on this would be appreciated.

    cheers
     
    tanyania, Jun 26, 2011 IP
  2. jonix

    jonix Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use this example - disables all cntr + combinations. I tested on IE 7 and Chrome. Should work on FireFox too. Won't work on Opera.

    Add onkeydown event for your control, for example:

    <textarea rows="10" cols="40" onkeydown="disable_cntr(event);" ></textarea>

    And here is function code:

    function disable_cntr(e)
    {
    if (e.ctrlKey)
    {
    if (e.preventDefault)
    {
    e.preventDefault(); //FireFox, Chrome
    }
    else
    {
    e.returnValue = false; //IE
    }
    }

    }
     
    jonix, Jun 27, 2011 IP