File Exchange

image thumbnail

Simulink Keyboard Input v2

version (10.9 KB) by Emanuele Ruffaldi
Allows to read input keyboard during Simulink simulation


Updated 02 Dec 2016

View License

Improvements respect original "Simulink Keyboard Input":
- second output for triggering key arrival (for Subsystems and Char)
- inherited sampling time
- close window on close
- handle of window as state so faster response
- Level-2 S-Function

Cite As

Emanuele Ruffaldi (2020). Simulink Keyboard Input v2 (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

Haihui Zhu


Works perfect. Thank you.

Nice! But as "abdulqader" said I would very much like to use this in Simulink Real-Time but the 'sfun_keyboard_input_v1_2.tlc' error is the problem. Do you have this?

Very nice! Would you have any idea on keeping track of how long a key is pressed?

Leo Müller

Great function!
How do I get the input window on top?
The input does not work whenever another figure pops up...

Fabian Beck

To fix the problem: "sfun_keyboard_input_v1_2 does not exist."
rename the Simulink model to a different name as the s-function.


Sav Deb

I get the same message of Chiara, using Matlab 2015b. Any solving?


when I tried to use it in real time code generation in simulink it gives me this message :
The corresponding "'sfun_keyboard_input_v1_2.tlc' file for the MATLAB S-function 'sfun_keyboard_input_v1_2' in block 'finished_senior_dipswitch1/change sound/Keyboard 1' must be located in the current working directory, the MATLAB S-function directory 'C:\Users\NNN\Documents\MATLAB', or the directory 'C:\Users\NNN\Documents\MATLAB\tlc_c'"
I know that the .tlc file is missing plz if you have it can u upload it
thank u

tri bui


i also have the same problem can somebody resolve this thing"sfun_keyboard_input_v1_2 does not exist. "
Thank you


If I save both of your files in the same folder, and I run the model (in Normal mode, is right?), it says sfun_keyboard_input_v1_2 does not exist.
Do you know why?
Thank you


Updated to R2016b with the support for non numeric handles

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Simulink Keyboard Input