<!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){
var div = $("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>
Pessoal, esse código está funcionando apenas com tecla enter (keycode 13). Se eu mudar pra outra tecla, como 39 por exemplo, e apertar, ele não executa a ação.