The tutorial and also many examples (such as earthball) contain key events. Your above code won't work as you can't assign variables outside a function.