File Exchange

image thumbnail


version (56.6 KB) by Florian Enner
Library for getting keyboard and joystick input into MATLAB


Updated 26 Jan 2018

View License on GitHub

MatlabInput allows MATLAB users to get input from keyboards and joysticks in a non-blocking manner. It contains two classes: HebiJoystick, and HebiKeyboard. HebiJoystick is a drop-in replacement for vrjoystick for users who don't have access to the Simulink 3D Animation toolbox. HebiKeyboard provides similar functionality, but for keyboard inputs.

% Add library

% Display all currently pressed keys whenever shift is up
kb = HebiKeyboard();
while true
state = read(kb);
down = find(state.keys('a':'z')) + 'a';
if ~state.SHIFT

The library was tested on Windows, Linux, and OSX on MATLAB 2015b, 2016a, and 2016b. However, it should run on any version >= 2013b. It makes use of the Java library (JInput) and does not support code generation).


Comments and Ratings (4)

Florian Enner

Are you using the released version or building from source? The source won't work by itself without first compiling it.

joe muguro

Undefined variable "us" or class "us.hebi.matlab.input.HebiKeyboard".
Error in HebiKeyboard (line 76)
this.obj = us.hebi.matlab.input.HebiKeyboard(driver, index);

Will Fonseca

Riley, just get a compiled version in:

Riley DeHaan

I am having difficulty getting MATLAB to correctly locate the hebi library functions and am receiving the following message from MATLAB (R2016b):

Warning: Invalid file or directory
> In javaclasspath>local_validate_dynamic_path (line 266)
In javaclasspath>local_javapath (line 182)
In javaclasspath (line 119)
In javaaddpath (line 71)
In HebiJoystick.loadLibs (line 65)
In HebiKeyboard.loadLibs (line 58)
In HebiKeyboard (line 75)
Undefined variable "us" or class "us.hebi.matlab.input.HebiKeyboard".

I am attempting to run the simple example code above on this page and have placed the hebi library in my MATLAB directory. I believe I have added the directory to the MATLAB path but here is the statement I used to include the library:

Would you have any suggestions to make the code run? I do not know Java.


description fix

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

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor