Code covered by the BSD License  

Highlights from
GetKeyWait

4.85714

4.9 | 7 ratings Rate this file 39 Downloads (last 30 days) File Size: 2.02 KB File ID: #8297

GetKeyWait

by

 

16 Aug 2005 (Updated )

Wait a certain time for a single keypress (v2.1, jan 2012).

| Watch this File

File Information
Description

GETKEYWAIT - get a key within a time limit
    CH = GETKEYWAIT(P) waits for a keypress for a maximum of P seconds. P should be a positive number. CH is a double representing the key pressed key as an ascii number, including backspace (8), space (32), enter (13), etc. If a non-ascii key (Ctrl, Alt, etc.) is pressed, CH will be NaN.
    If no key is pressed within P seconds, -1 is returned, and if something went wrong during excution 0 is returned.
 
   See also input,
            getkey, stoploop, yesno (FileExchange)

Acknowledgements

Getkey inspired this file.

This file inspired Waitinput.

MATLAB release MATLAB 6.5 (R13)
Other requirements works on most ML releases
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
13 Mar 2014 alex

excellent,very nice work!
very useful to my project
thank you very much!

13 Mar 2014 alex  
27 Nov 2010 Jos (10584)

@Sanchito: I suggest you implement the code/functionality of getkeywait into your own GUI directly.

24 Nov 2010 Sanchito

when i am running this program it is making another figure wherein i need to press enter for it to continue.

what I am saying it is that: I have a gui wherein a person enters a node number and then wait for the enter press key.... and i say if ch== 13 then run the rest of the program but when i do press enter it opens a figure wherein i need to press enter again for me to continue the analysis. Is there anyway of me avioding this figure in the middle just directly analysing it as soon as enter is pressed?

thanks

29 Oct 2009 Jesse Hopkins

Just what I was looking for

15 Sep 2009 Ehsan Negahbani

Great. Thank you Jos.
Is it possible to prevent the appearance of figure tab in the task bar?
I'm calling your function in a loop every second, and it works well, but there is continuous blinking between command window and windows task bar as your code opens and closes a figure window each time. I tried to off the 'visible' property of the figure, but it was not working...

26 Jun 2008 kk kk

thank you...fantastic work

27 May 2008 Iohan Sandoval

very good job! thanks

17 May 2007 Joseph Hollmann

Great submission

26 Feb 2006 Inese Steinbahs

Thank You! This function worked out for my program wounderfully!

16 Aug 2005 urs (us) schwarz

in need of some re-engineering as it creates a new timer object every time it is called, which could be deleterious when used in a long loop, for instance.

Updates
17 Aug 2005

Timer object was not deleted which could cause problems after (many) repetitive calls. Thanks to us.

17 Aug 2005

Timer object was not deleted which could cause problems after (many) repetitive calls. Thanks to us.

23 Apr 2009

updated checks and output

30 Jan 2012

changed some figure properties; added check for figure existence

Contact us