Home › Forums › JavaScript › Keyup not working › Re: Keyup not working
December 20, 2012 at 1:28 am
#118217
JohnMotylJr
Participant
@Cathyk : First, if you plan on using jQuery then you need to reference it locally or through a cdn. Add this:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
I slightly modified your code as well as included an example.
function getAway() {
window.open('http://omg.yahoo.com/news/','_newtab');
window.location.replace('http://omg.yahoo.com/news/');
}
$(document).keyup(function(e) {
if (e.which === 27) {
getAway();
}
});
jsFiddle because CodePen was being a weirdo. I hope this helps.