Have you imported the jQuery file, the reason why I ask is you've not tagged with jQuery
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" />
Maybe you missed to add this script.
$(document).keyup(function (e) { // this belongs to jQuery