On Mar 31, 2009, at 8:27 PM, Debajit Adhikary wrote:
I'm trying to write an app where I need to accept keypresses, and call
a function whenever the user has stopped typing (or when there is a
specified delay between keystrokes).
How do I measure the time between two keystrokes?
Measuring the time between keystrokes (or events of any other kind) is
easy. Each keystroke generates an NSEvent and NSEvent has a -
timestamp method.
The real problem is that you want to do something when there _hasn't_
been an event for a certain time period. For that, I recommend that
you schedule an NSTimer, and keep pushing back its firing time each
time you get a keystroke.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com