Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple code Help

Status
Not open for further replies.

giulian

Technical User
Jul 27, 2003
6
AU
Hi, I have code such as the following in my flash file

search_btn.onRelease = function () {
found = false;
searchForWord();
}

what this does is it allows for text to be typed in a text bar and then searched with the search_btn. It works great however can anyone help me please on how to add in this code to also accept keypress of Enter. So that the user can click the button or just press enter.

Thanks in advance
 
From Flash help for Button.onKeyDown.

Code:
my_btn.onKeyDown = function() {
  trace("onKeyDown: "+this._name+" (Key: "+getKeyPressed()+")");
};
function getKeyPressed():String {
  var theKey:String;
  switch (Key.getAscii()) {
  case Key.BACKSPACE :
    theKey = "<BACKSPACE>";
    break;
  case Key.SPACE :
    theKey = "<SPACE>";
    break;
  default :
    theKey = chr(Key.getAscii());
  }
  return theKey;
}

It always pays to look around in the help files :)

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top