Good morning everyone, I have a page that contains Onkeydown='return false'
in its <body>
what disables the use of the keyboard. But I need it to be able to be activated at a given moment, more specifically to write to a input
, for which it is necessary to remove the Onkeydown but I want it to be re-enabled after the action of writing to the input
.
My question is:
Is there a way that I can remove the onkeydown
del <body>
so I can write to input
it, and after that, put the onkeydown
back in again <body>
using JavaScript?
Thank you very much for your attention. :)
Is there a specific reason to disable the keyboard?
I think it's a very bad idea and I'll explain with an example: Many times I use the keyboard instead of the mouse to scroll through pages or even to go back in history.
In short, if you are not going to take into account fussy users (such as your server) or others with different abilities... read on.
It is not convenient to assign the event in the same tag
<body onkeydown="return false;">
. The best thing is to create a Javascript function where you can analyze in which cases you are going to allow the use of the keyboard: