How to disable all keyboard keys?

I am looking for an option to disable all keyboard keys in a text box. I found some examples on the Internet to disable some of them, but how can I disable the entire keyboard?

+3
source share
4 answers

You can disable the text field using the disabled attribute . Or you can only read it using the readonly attribute. readonly - as disabled, except that it does not prevent the user from clicking or selecting in the text box.

And if you really need to do this using javascript, then this will do it (using jQuery):

<textarea rows=3 cols=20></textarea>

$("textarea").keydown(false);

You can try it here: http://jsfiddle.net/7n4G4/1/

+14

, textare textarea, , - :

textearea.onkeydown = textarea.onkeypress = function() { return false };

, , , ... readonly:

textarea.readOnly = true

/ , ( ).

+2

readonly, ,

<textarea name="text" readonly>

,

<textarea name="text" disabled>

<textarea name="text" id="text-input">

jQuery

$("#text-input").on("keydown keypress keyup", false);
+2
 document.getElementById('ID OF TEXTAREA').onkeypress=function(){return false;}

, , disabled .

0

All Articles