How do I capture a CTRL-S without jQuery or any other library?

前端 未结 7 509
别那么骄傲
别那么骄傲 2020-12-09 04:44

How do I go about capturing the CTRL + S event in a webpage?

I do not wish to use jQuery or any other special library.

Thanks for your

7条回答
  •  情话喂你
    2020-12-09 05:04

    Oops you wanted simultaneous, changed code to reflect your scenario

    function iskeyPress(e) {
              e.preventDefault();
                if (e.ctrlKey&&e.keyCode == 83) {
                   alert("Combination pressed");
    
                   }
                  return false;//To prevent default behaviour         
                  }
    

    Add this to body

      
    

提交回复
热议问题