<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</style>
</head>
<body>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><script>$(document).ready(function(){$(document).keypress(function(x){if(x.wich==13||x.keyCode==13){vardiv=$("div");
div.animate({height: '300px', opacity: '0.4'}, "slow");
div.animate({width: '300px', opacity: '0.8'}, "slow");
div.animate({height: '100px', opacity: '0.4'}, "slow");
div.animate({width: '100px', opacity: '0.8'}, "slow");
}
});
});
</script>
</body>
</html>
Personal, this code is only working with key enter (keycode 13). If I change to another key, like 39 for example, and press, it does not perform the action.