I am trying to press button in animated way by pressing Enter
keyboard. I can click button when Enter
is pressed, but animation is not playing. But when I click the button with mouse it is animating. My purpose is not using mouse
but Enter
keyword. How can I solve this problem. Any help is appreciated.
function myFunction() {
console.log('pressed');
}
$(document).keypress(function (event) {
if (event.keyCode === 13 ) {
// $("#btnSearch").click();
myFunction();
alert('btnSearchClick');
}
})
.button {
padding: 15px 25px;
font-size: 24px;
text-align: center;
cursor: pointer;
outline: none;
color: #fff;
background-color: #000000;
border: none;
border-radius: 15px;
box-shadow: 0 9px #999;
margin-top: 20%;
margin-left: 45%;
}
.button:hover {background-color: #000000}
.button:active {
background-color: #000000;
box-shadow: 0 5px #666;
transform: translateY(4px);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="bigg">
<div class="item-animate">
<button class="button" id="btnSearch">Start</button>
</div>
</div>
I took animated button w3schools