• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Measuring time between keypresses?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Measuring time between keypresses?


  • Subject: Re: Measuring time between keypresses?
  • From: Ken Thomases <email@hidden>
  • Date: Tue, 31 Mar 2009 20:33:49 -0500

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 (email@hidden)

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:
This email sent to email@hidden


References: 
 >Measuring time between keypresses? (From: Debajit Adhikary <email@hidden>)

  • Prev by Date: Re: Measuring time between keypresses?
  • Next by Date: How do I time a Cocoa app?
  • Previous by thread: Re: Measuring time between keypresses?
  • Next by thread: How do I time a Cocoa app?
  • Index(es):
    • Date
    • Thread