espaço em string usando se em jQuery

if(key.indexOf(' ') >= 0){
  alert();
}
Ankur