Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
2D Collision from Explore Science
Wait for X seconds, go to marker
Generic behavior to check Windows Platform
Billenium Transitions Xtra v2
Setup Anim
Bilinear Resample Algorithm
EZIO
Sound shifting
Set ButtonsEnabled Property of a Flash Cast member
Push Dial-Alphamania
 

 

 

Behavior Generic behavior to detect if the key has been pressed

Added on 3/24/2002

 

Compatibilities:
behavior D6_5 D7 D8 D8_5 PC US

Required Xtras:
KeyboardControl Xtra Standard

This item has not yet been rated

Author: Shockdev

Checks if the key has beed pressed during the time period between two events (mouse clicks). Very useful if you need to have statistics of keyboard usage.

-- Generic behavior to detect if the key has been pressed
-- KeyboardControl Xtra 1.1 or later required

property Key

on getPropertyDescriptionList
  set description = [:]
  addProp description, #Key, [#default: "", #format:#string, #comment:"Key to check for keystroke:"]
  return description
end

on getBehaviorDescription
  return "Checks if the key has beed pressed during the time period between mouse clicks"
end

on mouseDown
  detectKey
end

on detectKey
  set Ok = KeyboardControlKeyBeenPressed(Key)
  if getAt(Ok,1) = 0 then
    case getAt(Ok,3) of
      0: set WasPressed = False
      1: set WasPressed = True
    end case
    if WasPressed = True then
      alert ("The " & Key & " key WAS PRESSED since the last click")
    else
      alert ("The " & Key & " key WAS NOT PRESSED since the last click")
    end if
  else
    -- An error has occured, show error code
    alert("Error: " & getAt(Ok,1) & " - base error code")
  end if
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail