0

A client of mine asked me if it was possible through a webapp to completely disable both client's keyboard & mouse. Ideally in jQuery or Html5.

I saw a way to do it but only on the web page not the whole keyboard.

Community
  • 1
  • 1

2 Answers2

0

Have you tried something like

$(document).ready(function () {
    $(document).bind("keypress", function (e) {
        // Prevent any key
        return false;
    });

    $(document).bind("click", function(e) {
        // Prevent clicks
        return false;
    });
});

It should work, but not sure if it's cross browser.

Added the click handler also.

Kami
  • 19,134
  • 4
  • 51
  • 63
  • Hello! This is a good way to block keyboard inside the web-page. But is there a way to completely block keyboard & mouse even out of the browser? – user1808863 Nov 09 '12 at 16:25
  • Through a browser? No. You can perhaps create a desktop application that facilitates this, but maybe a better option is to unplug the keyboard/mouse and use remote access to control the PC if required. Can you give more information on the context of this? – Kami Nov 09 '12 at 18:10
  • OK. Thank you for your answer. Here is the situation. The teacher wants through my webapp to block the student's keyboards connected just clicking on a button. Is that possible? – user1808863 Nov 09 '12 at 21:22
  • This is not possible through the browser. You can perhaps write a desktop application to achieve this. – Kami Nov 11 '12 at 02:36
  • @ValentinVrinceanu Without understanding your application of this technique it is difficult to judge what is/isnt working. Can you open a new question with the details of your approach and list any problems you are experiencing. – Kami May 30 '13 at 11:16
  • i just tried on a webpage to stop all the keyboard and mouse actions using your code. – Valentin Vrinceanu May 30 '13 at 13:51
0

Using AutoIt3, for example, it's very simple. But from webapps, block mouse and keyboard for all the OS' environment isn't possible.

In AutoIt3, here's an example:

; By default, AU3 add an tray icon for closing the app. No longer:
#NoTrayIcon
; For >=Vista, windows will require administrator privilleges to do that
#RequireAdmin
; Now...
BlockInput(1) ; mouse and keyboard are both lockeds!
While 1
   Sleep(100) ; loop for pause script
WEnd

Just compile that and run.

Jefrey
  • 1