How can I disable all keyboard keys?

后端 未结 4 570
你的背包
你的背包 2021-01-12 09:14

I am searching for a possibility to disable all keyboard keys in a textarea. I found some examples on the web to disable some single ones but how can I disable the whole key

4条回答
  •  执笔经年
    2021-01-12 09:57

    You can disable the textarea using the disabled attribute. Or you can make it read only using the readonly attribute. readonly is like disabled except it doesn't prevent the user from clicking or selecting in the textarea.

    And if you really need to do it with javascript something like this will do it (using jQuery):

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

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

提交回复
热议问题