javascript: how to check a property is undefined
<p>I have codes below.</p>

<pre><code>elem.onkeypress=function(e){
 if( (e.which===undefined?e.keyCode:e.which)==13 ){
   //dosomething
  }
}
</code></pre>

<p>at IE8, it occus erros:  <code>'which' is null or not an object</code></p>

<p>how to fix this problem.</p>
