kbd

Version 1.1.0.0 (1022 Bytes) by Peter Caday
Replacement for the keyboard function that supports enabling/disabling
175 Downloads
Updated 11 Jun 2014

View License

This function is like MATLAB's useful built-in 'keyboard' function, which lets you stop in the middle of a function, examine or change variables, and do debugging.
The new functionality in kbd is that you can disable or enable it as you like. For instance, if you have a function that calls kbd, you can type 'kbd off' to run the function straight through, just as if you had removed the calls to kbd. Later, if you want to re-enable the kbd command, just type 'kbd on'.
To use this command, you will need to compile the MEX C-file (for those new to MEX files: navigate in MATLAB to the folder containing kbd.c, type 'mex kbd.c', and you will get a file starting with kbd.mex... that you can put anywhere on your MATLAB search path.)

The syntax:

kbd
-- enters keyboard mode, if enabled
kbd off
-- disables the kbd command
kbd on
-- enables the kbd command
s = kbd('state')
-- returns 1 if kbd is currently enabled and 0 otherwise.

For more information on MATLAB's keyboard command, you can check out the MATLAB documentation.

Update 6/10/14: "dbquit" now works inside kbd as it should.

Technical notes:

- There is no reason you have to do this with MEX, but the advantage is that MATLAB can't step through MEX files, so when executing kbd, it stops in the function calling kbd instead of inside kbd itself.

- For some reason, if you use dbstep to step through code after entering kbd, you have to type dbstep twice in order to move onto the next command. I'm not sure why.

Cite As

Peter Caday (2024). kbd (https://www.mathworks.com/matlabcentral/fileexchange/46682-kbd), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Desktop in Help Center and MATLAB Answers
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.1.0.0

Update 6/10/14: "dbquit" now works inside kbd as it should.

1.0.0.0