Home > By category > Scripts >Development Tools > Non-wait detection of keyboard input (including MEX implementation)



Non-wait detection of keyboard input (including MEX implementation)

  • Downloads: 
  • Views: 
  • Rating:

These functions retrieve the last key pressed in the command window without having to explicitly wait for input. Useful for situations where code is executing and you want to poll for keyboard input but you don't want hidden figures. For example, mexKbhit can be used to interrupt a MEX function while it's executing.

The code taps into the command window's key press callback function. Each time a key is pressed, a small piece of m code is run to save the key event. A call to kbhit (or mexKbhit in MEX code) will return information about the key event, such as the ascii code and the related character, and whether Control, Alt and/or Shift was also entered.

Warning : mexKbhit calls the matlab function kbhit. While CTRL+C doesn't interrupt MEX functions, it will interrupt matlab functions called by a MEX function. Therefore, the key combo CTRL+C may cause problems when your MEX function is executing mexKbhit.

Big acknowledgements to Yair Altman in the MATLAB newsreader thread "java: add keyListener to command window", for providing the exact code needed to set up the key press callback.

Files:
kbhit.m - matlab function
mexKbhit.h - MEX c file header
mexKBhit.c - MEX c file, including instructions for building the library
mexKbhitDemo.c - demonstration code for using the MEX library.

Example use of Matlab function :

kbhit('init');
fprintf(1, 'Five seconds to type something ...');
pause(5);
key = kbhit; fprintf(1, 'Character : %cn', key);
key = kbhit('struct'); fprintf(1, 'Key struct :n'); disp(key)
[key, ctrlc] = kbhit('event'); fprintf(1, 'Key event :n'); disp(key)
fprintf(1, 'Ctrl+c pressed ? %dn', ctrlc);
kbhit('stop')

Example use of MEX library :

clock_t t;
struct key k;
init_mexKbhit();
t = clock();
// poll for 5 seconds
mexPrintf("Wait 5 seconds ... ");
mexEvalString("drawnow");
while ((clock()-t)/CLOCKS_PER_SEC < 5) {
k = mexKbhit();
if (k.character == 'C' && k.ctrl == 1) {
mexPrintf("interrupted by Ctrl+c! ");
break;
}
}

Free download from Shareware Connection - These functions retrieve the last key pressed in the command window without having to explicitly wait for input

Publisher: Amanda | License: Shareware
Version: 1.0 | Size: 10 KB | Platform: Matlab, Scripts
Released Date: 04-03-2013 | Rating: 0 | Title: Non-wait detection of keyboard input (including MEX implementation)

Author Url: http://www.mathworks.com
Program Info Url: http://www.mathworks.com
Download Url: http://www.mathworks.com/matlabcentral/fx_files/30622/1/mexKbhit.zip

More downloads from Non-wait detection of keyboard input (including MEX implementation) publisher Amanda:

Scale bar for 2D axes - SCALEBAR creates a scalebar on an axes SCALEBAR SCALEBAR OFF SCALEBAR(PARAMETER, VALUE, ...) SCALEBAR(HAXES, PARAMETER, VALUE, ...) H = SCALEBAR(...) Draws a scalebar on the axes and returns handle to the scalebar.

Fast 2D histogram calculation - Hist2D performs a fast calculation of 2D histograms

Non-wait detection of keyboard input (including MEX implementation) keywords:
Non-wait detection of keyboard input (including MEX implementation) related downloads:

Music Library Organizer Pro - Music Library Software for Windows. Music library database maintenance system for private, public, corporate libraries. Our library software helps you to catalog cds, tapes, dvds, organize member information, keep track of the circulations.

Regular Expression Component Library for VC9 - Regular Expression Component Library for VC9 is designed as an easy-to-use library for searching and / or replacing strings or data in files using regular expressions in non-managed C++ code.

Movie Library Organizer Pro - Movie Library Software for Windows. Movie library database maintenance system for private, public, corporate libraries. Our library software helps you to catalog dvds, video tapes, cds, organize member information, keep track of the circulations.

WMA Tag Library - WMA Tag Library will provide users with a component that helps you develop applications for reading as well writing tags in WMA audio files.

Keyboard Spectator Pro - Keyboard Spectator is a multifunctional keyboard tracking software (a.k.a. key logger) that is widely used by both regular users and IT security specialists to record keystrokes.

Shareware Connection periodically updates pricing and software information of 'Non-wait detection of keyboard input (including MEX implementation)' from company source 'Amanda' , so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft,  Using 'Non-wait detection of keyboard input (including MEX implementation)' crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of Non-wait detection of keyboard input (including MEX implementation).

New Reviews

Panda Cloud Cleaner - PC security has become a tricky and complicated subject both for home users and network supervisors, with complexity and risk factors multiplying over the years. Using a single antivirus app may not be enough anymore. That explains why many users ...

Voila - Mac users have never felt much hassle as far as image editing goes, given the fact Apple itself offers two compelling image editing suites. However, serious users may find the inbuilt screen capturing options basic, the fact they are much ahead ...

Poser - The concept of 3D animation and modeling may seem amazing to the viewers but those who are into the industry know it is no cakewalk. Majority of 3D animation and modeling software known for some of the amazing animations and CGI work in films ...

PCMark 8 - Not every PC user would have penchant for running new benchmarks and benchmarking software in their computers. It is only hardcore gamers and seasoned users who like tinkering around with various settings in PC benchmarking tools. Such apps also ...

Adobe Muse CC 2014 - There was a time when Dreamweaver used to be the most widely used web design app and competitors from Microsoft or other small players used to lag behind. While the powerhouse app still enjoys a humongous user base worldwide, emergence of new ...

TrustPort Tools - Nowadays, PC users need to deal with several types of third party apps to ensure security and privacy of data. From encrypting files to getting rid of sensitive data, the needs can be numerous. There are many such tools that can be used in this ...

DriverPack Solution Professional - To keep your laptop or desktop performing well consistently, it is important to pay attention to some aspects. Using top antivirus utility, cleaning up junk feels periodically are some such examples. However, you also need to keep drivers of ...

Pixelmator - There is no denying the fact that Mac users are often left with fewer third party app choices than those who use Windows based PCs. However, when it comes to imaging, the situation is a little better. If you want a versatile image editor for Mac ...

Cubase Artist - Professional audio editors and artists dealing in MIDI composition have a soft corner for Steinberg Cubase Artist. Its origin can be traced back to Atari ST and in later years, the app made way into PCs and Macs. The latest version is a flexible ...

DVDFab DVD Copy - While a lot of computer users are switching from optical media to external and cloud storage services, a section of them still counts on DVD for storage and movie watching. At times it also becomes necessary to copy those DVDs that are getting ...




New Downloads

MP3 Editor for Free

MP3 Editor for Free is perfect
for home-studio recording and
audio editing. It has dozens
of audio effects, audio ...

Honeyview

Honeyview is very fast image
and archived image viewing
software. It allows viewing of
images within an archive
without ...

Multiple Plot

multiplot - 2D-line plots on
several axes with common
x-axis multiplot(XDATA,YDATA,'
PropertyName',PropertyValue,..
.) ...

BPSK Simulation for AWGN &
Rayleigh Channels

We simulate the generation of
random variables r0 and r1,
which constitutes the input to
detector.

RDFS.rb

RDFS.rb is a forward-chaining
inference engine that
implements the RDF Schema
(RDFS) entailment rules.

Gnome Helper

Gnome Helper is a little
administrator module that will
allow you to easily search
JSDE (Joomla Developers Search
...

bdf_trim

Extract specific Channels from
BIOSEMI DATA FILE (BDF)

Real Number to N-digit
String

Floors a real number and
converts it to an N-digit
string

Diversity

Plot between Ebno and SER in
the presence of diversity

Correlation elimination in
multivariate correlated
data

USAGE: [Y CovY] =
Correlation_elimination( X )

MySQL backups manager

MySQL backups manager script
will make saving and restoring
your MySQL databases.

Simulink Model of the IEEE
802.11n PHY Layer model

See the paper describing the
model at