# Suppressing keyboard output during experiment.

**URL:** <https://psychtoolbox.discourse.group/t/suppressing-keyboard-output-during-experiment/1724>\
**Category:** Uncategorized\
**Created:** [October 27, 2006, 8:17pm UTC](https://psychtoolbox.discourse.group/t/suppressing-keyboard-output-during-experiment/1724 "2006-10-27T20:17:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [October 27, 2006, 8:17pm UTC](https://psychtoolbox.discourse.group/t/suppressing-keyboard-output-during-experiment/1724/1 "2006-10-27T20:17:10Z")

</div>

I'm not sure if this is a MATLAB question or a Psychtoolbox question. Whenever I run an   
experiment using a window created with the Screen('openwindow') command, all of the   
keypresses are treated as normal typing, and I end up with an unwanted string of   
characters in my command window or my code. It's more of a nuisance than anything, but   
it would be nice if there is a way to fix the problem. Does anyone else have this problem or   
know how to fix it? I'm running PTB 3.0.8 on MATLAB 7 and OSX 10.3.9.   
  
Eric  
[vanbogaert.eric@...](mailto:vanbogaert.eric@...)

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [October 28, 2006, 12:45am UTC](https://psychtoolbox.discourse.group/t/suppressing-keyboard-output-during-experiment/1724/2 "2006-10-28T00:45:59Z")

</div>

Another method with PTB 3.0.8 and Matlab running with Java enabled is  
to add a: ListenChar(2) at the top of your script and a ListenChar(0)  
at the end to enable/disable routing of keypresses to Matlab. This  
doesn't work in -nojvm mode and if your script crashes, you'll have to  
press CTRL+C once to reenable keyboard input.  
  
I like the smart solution of Ted Wright though :)  
-mario  
  
--- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Charles E. (Ted) Wright"  
\<cew@...\> wrote:  

> \>  
> \> If what you are typing during your experimental run does not include the  
> \> Enter key and if you are willing to type the Enter key at the end of

your  

> \> run, you can easily solve this problem by including the line  
> \>   
> \> input('', 's');  
> \>   
> \> at the end of your code. There are probably elaborations of this

strategy  

> \> that will work if either of the two assumptions above are not true,

but I  

> \> have not given them any thought.  
> \>   
> \> Ted Wright  
> \>   
> \> On Fri, 27 Oct 2006, eric.vanbogaert wrote:  
> \>   
> \> \> I'm not sure if this is a MATLAB question or a Psychtoolbox

question. Whenever I run an  

> \> \> experiment using a window created with the Screen('openwindow')

command, all of the  

> \> \> keypresses are treated as normal typing, and I end up with an

unwanted string of  

> \> \> characters in my command window or my code. It's more of a

nuisance than anything, but  

> \> \> it would be nice if there is a way to fix the problem. Does anyone

else have this problem or  

> \> \> know how to fix it? I'm running PTB 3.0.8 on MATLAB 7 and OSX 10.3.9.  
> \> \>  
> \> \> Eric  
> \> \> vanbogaert.eric@...  
> \> \>  
> \> \>  
> \> \>  
> \> \>  
> \> \>  
> \> \> Post your message to: [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com)  
> \> \> Please indicate OS9, OSX, or WIN version, and include your full name.  
> \> \> Denis Pelli, David Brainard, and Allen Ingling.  
> \> \> [http://psychtoolbox.org](http://psychtoolbox.org)  
> \> \>  
> \> \> Yahoo! Groups Links  
> \> \>  
> \> \>  
> \> \>  
> \> \>  
> \>
