Recently do the front desk, to do a button on the special effects, requirements are pressed down to see is pressed down the feeling. Well, just follow the effect, and the background picture of the two buttons that have already been used in the PS process. Then it should be using CSS and JS to control the effect of it.
Before learning JS has always had a keydown,keyup impression, literally does not seem to be the key press down and open the English, so use this function to try. Later I have not come out of the desired effect, I was puzzled, and then Baidu know that the mouse button and keyboard keys are not the same.
Keydown,keyup: A keyboard key that belongs to you
Mousedown,mouseup: The mouse button that belongs to you
We can't confuse it.
Here's My Code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
The corresponding Keydown,keyup event annotation, you use the mouse to press that button, will appear effect. Letting go will restore the original effect.
If you try to comment out the Mousedown,mouseup event, you first select the button, and then casually on your keyboard to press which button will also appear effect, release and restore.
We can debug, as the above code I quoted the jquery JS file, the button background picture is their own preparation, everyone debugging words to prepare the above two can be.
For a further explanation of the KeyDown event, the W3cschool is very detailed, and the following example is the example on W3cschool, which can be used to listen to an example of a specific key on your keyboard that you press: (mostly. which this attribute)