Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Keyup not working Re: Keyup not working

#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/');
}

$(do​cument).keyup(function(e) {
if (e.which === 27) {
getAway();
}
});​

jsFiddle because CodePen was being a weirdo. I hope this helps.