A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Capturing ALPANUMERIC key Strokes only

Hybrid View

  1. #1
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991

    Capturing ALPANUMERIC key Strokes only

    Hi guys

    I made this little multi field notepad application.. experimenting..

    i need a way to flag for "SAVE" whenever something has changed in the document.. like when you use a word processor, you get an asterisk at the end of the document title whenever you need to save your document..


    i can use a regular Listener object, and check for keystrokes.. but i'd hate to do a condition for each keyCode..

    if i just simply tested for keyListener.onKeyDown then it'll flag to save the document even if shift, numlock, control keys, or one of them kind of keys are pressed..

    any more efficient way for this?

  2. #2
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991

    pressing CNTRL+S or any key makes strange suares in my textFields

    when i hit CNTRL+ any key while a textField / textField component is on focus i get these square looking characters 


    how do you avoid them? 


    is there a way to filter keystrokes, like if CNTRL is not pressed then go ahead and type it in..

    anyone?

  3. #3
    Harmony & Justice Veniogenesis's Avatar
    Join Date
    Jul 2002
    Location
    Washington D.C.
    Posts
    4,434
    Perhaps you can use Key.getAscii to get the ASCII code of the pressed keys. (ASCII table: http://en.wikipedia.org/wiki/ASCII)
    Code:
    keyListener.onKeyDown = function() {
        x = Key.getAscii();
        if((x>=48 && x<=57) || (x>=65 && x<=90) || (x>=97 && x <= 122))
        {
            //It is a digit or letter
            //ASCII codes 48 through 57 represents 0-9, 65 to 90 represent A-Z, and 97 to 122 represent a-z
        }
        else
        {
        //Not digit or letter
        }
    };
    Note also the ASCII codes for certain symbols like space (32) and period (46). By the way, CTRL will return zero (0).

    Let us know if that accomplishes what you want.

    Regards,
    Venio
    Flash Kit Moderator . Duke University
    Thomas Jefferson High School for Science and Technology

  4. #4
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991
    @Venio.. i hoped for something more simplier..but yeah that's lot better than keyCodes.. thanks for reminding me..

    what about my second problem? any ideas with that? (my second post)

  5. #5
    Harmony & Justice Veniogenesis's Avatar
    Join Date
    Jul 2002
    Location
    Washington D.C.
    Posts
    4,434
    Oh, I just noticed I might have misread your question. In your case, I'm guessing you would only have to wait for when x = 0, 8, and 26. (The ASCII code of CTRL, F1, F2, F3, ESC, Page Up, Page Down, Arrows, Insert, Home, End, etc. have a value of zero. Escape is 27 and backspace is 8.)

    You might be able to implement the keyListener as well to check for the CTRL problem (where the ASCII value equals zero).
    Flash Kit Moderator . Duke University
    Thomas Jefferson High School for Science and Technology

  6. #6
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991
    thanks much for the input..

    what about this problem..

    requote:
    when i hit CNTRL+ any key while a textField / textField component is on focus i get these square looking characters 


    how do you avoid them? 


    is there a way to filter keystrokes, like if CNTRL is not pressed then go ahead and type it in..

    anyone?
    my CNTRL+S function is working neatly, but whenever i do it in a text field those damn squares are coming up

  7. #7
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991
    still cant figure this annoying thing out..

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