Implements a JavaScript control keyboard that performs actions while pressing certain keys at the same time.

Source: Internet
Author: User

Preface: Before the understanding of the introduction of a foreign cool website, one of the sensitive website with the simultaneous holding "Q, A, p, l" to watch the video let go immediately force stop (manual squint). The actual use of this feature, I think it is possible to do some small system permissions control can be used, so as to eliminate the login and permissions-related functions.

Example 1: Increase permissions while holding "~, L, J, W," at the same time

1.1 JS section:

Key permissions Verify    var iscrawler = false;//crawler rights    var keybuf = {};    function KeyDown (e) {        var evt = e | | window.event;        Keybuf[evt.keycode] = true;        Whatisdown ();    }    function KeyUp (e) {        var evt = e | | window.event;        Keybuf[evt.keycode] = false;        Whatisdown ();    }    function KeyPress (e) {        whatisdown ();    }    function Whatisdown () {        var str = "";        if (keybuf[74] = = True && keybuf[76] = = True && keybuf[87] = = True && keybuf[192] = = True) {            Console.log (' You opened the Authority ');            Iscrawler = true;//Open Permission        } for        (k in keybuf) {            if (keybuf[k] = = true) {                str + k + ";";            }        }    }

1.2 HTML section:

<body  onkeydown= "KeyDown" (event), "onkeyup=" KeyUp (event), "onkeypress=" KeyPress (event); >

  

Implements a JavaScript control keyboard that performs actions while pressing certain keys at the same time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.