A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: keypress help

  1. #1
    the pit of gold
    Join Date
    Mar 2005
    Location
    malvern
    Posts
    34

    keypress help

    hey, i know that you can use the keypress with up,down,left,right and some other buttons,
    but what is the script for normal letters, e.g. a, s, d, w

    any help would be good, thanks

    jason


  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    You could use a button with a keyPress event,
    Code:
    on (keyPress "a") {
    	trace("a was pressed");
    }
    or have a listener object to detect keypresses,

    Code:
    var kl = {};
    kl.onKeyDown = function() {
        if (Key.getCode() == 65) {
            trace("a was pressed");
        } else if (Key.getCode() == 68) {
            trace("d was pressed");
        }
    };
    Key.addListener(kl);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center