Change Focus after button press
I have a simple button that calls a routine onClick. I use
document.getElementById('Start').disabled=true;
to disable the button so it can not be pressed again. On most things there is no problem after that. In one instance I need to detect key presses, or rather key releases once the button is klicked.I use
document.onkeyup=WichKeyPressed;
to detect the key press. This works fine if I do not disable the button, but it does not work if I disable the button.
It must be a focus problem. If I click the mouse on a blank area on the screen, the key press is detected with or without disabling the button. I have tried changing the fo开发者_C百科cus to several other elements, but so far no go. I have even given the BODY an id and tried to change focus to it, but the results remain the same.
I would appreciate any ideas on the subject. Thank you.
Instead of disabling the button, you could just add a CSS class and set a flag preventing the action from happening again when the button is clicked.
精彩评论