Prevent execution of Tab key in site using Javascript

Discussion in 'JavaScript' started by bagfull, Jan 9, 2010.

  1. #1
    Hi,

    I have a site and in that I don't want to users pressing tab key and also shift + tab key.

    So I need a small javascript code for preventing execution of tab key and Shift+Tab Keys.

    Please help me.. I just need this small help.
     
    bagfull, Jan 9, 2010 IP
  2. Maujor

    Maujor Peon

    Messages:
    30
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <script  type="text/javascript">
    document.onkeydown = disableTabKey
    function disableTabKey(e) {
    var keycode;
    (window.event) ? keycode = window.event.keyCode : keycode = e.which;
    if (keycode == 9 || keycode == 16) return
    }
    </script>
    Code (markup):
     
    Maujor, Jan 10, 2010 IP