Functions assigned to escape key

I’m having a tough time getting the escape key to use a function.

Every tutorial I go to it says that you need to

import.flash.events.KeyboardEvent

but when I use KeyBoardEvent in a function nothing happens. I get an error that says it couldn’t load

Why is this?