<div>You want args.Key instead of e.Key. The standard event signature is function(object sender, EventArgs args).</div>
<div> </div>
<div>But the better way to do this is to set the OK button to be the default button. In Winforms, this is a property on the form:</div>
<div>form.AcceptButton = self.ok_button.<br><br></div>
<div class="gmail_quote">On Mon, Feb 22, 2010 at 12:55 PM, Ken MacDonald <span dir="ltr">&lt;<a href="mailto:drken567@gmail.com">drken567@gmail.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hi,<br>I&#39;ve inherited an I-P app, and trying to make some sense of it... It has a login page, with several text fields including &quot;user&quot; and &quot;password&quot;; and &quot;OK&quot; and &quot;CANCEL&quot; buttons. Right now, you enter the user/password into the text fields, and then have to click the &quot;OK&quot; button to login. Customer would like this to work like most other apps, where filling in user/password and then typing the &quot;Enter&quot; key would also initiate the login. I&#39;ve searched the I-P book and googled, but I can&#39;t find a workable reference to how to write a handler to determine the Enter key has been hit - actually, I was able to catch a keyboard event:<br>
<br>pwd_fld.KeyDown += on_enter<br><br>def on_enter(self, e, args)<br>    # what here???<br><br>but unable to determine what the keystroke is - &quot;Iron Python In Action&quot; suggests:<br><br>if e.Key == Key.Enter:<br>
     # start login<br><br>but I get the error &quot;e has no attribute &#39;Key&#39;&quot;<br><br>Clues appreciated....<br><font color="#888888">Ken<br></font><br>_______________________________________________<br>Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br>