Fix compile error's 

 - fix keyCode #68, #320
 - define escapeRegex
 - removing undeclared variable