Yansong, It would suggest it may be better to write the software such that it is independent of time key is pressed. ie. act on keypress but don't respond to further key presses until original key is released. You also normally debounce the key with a small delay (30-50ms maybe). ie. If keypress detected wait 30ms if key still being pressed, act wait till key released small delay Regards David Huisman -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads