How to initiate a alertbox on keypress in tinymce


i’m trying to create a alert if @ key is pressed in tinymce and i don’t know how to do it in tinymce. I would also like to know how tinymce can get an input by a mouse click as i’m trying to create a facebook style tagging system, as this would help me in getting user clicked name inside tinymce3 editor.
the code i9 tried so far:

          var editor=$("#editor");
          editor.on("keydown", function(e){