The following should work, but won't in older versions of IE.
// on(..., function() {
if( this.value.substr(0,this.selectionStart).match(/(?:^|\r?\n\s*)$/)
&& this.value.substr(this.selectionStart).match(/^(?:\s*\r?\n|$)/)) {
console.log("empty");
}
EDIT search now explicitly looks for a newline, with further whitespace optional.