JS block keyboard is not available with the right mouse button is not available

  • 2020-03-29 23:47:36
  • OfStack

Today did 2 small experiment, screen keyboard can not be used to screen the mouse can not be used

Experiment one: the masking keyboard is not available

The keyboard has three events

A, keydown: it is triggered when a key on the keyboard is pressed, and it will continue to be triggered when a key is pressed

B. Keypress: triggered when a key is pressed and a character is generated, that is, Shift,Alt,Ctrl and other function keys are ignored

C, keyup: triggered when a key is released


    <script language="javascript">
        function block() {
            event.keyCode = 0;
            event.returnvalue = false;
            alert(" � � is unavailable .");
        }
        document.onkeypress = block;
    </script>

Experiment two, blocking the mouse right weng is not available


      <script language="javascript">
        function block(oEvent) {
            if (window.event) {
                oEvent = window.event;
            }
            if (oEvent.button == 2) {
                alert(" Mouse and mouse are not available ");

            }
        }
        document.onmousedown = block;
    </script>

Ha ha ~ as above to achieve the blocking function


Related articles: