function [key, el]=EyelinkGetKey(el) % USAGE: [key, el]=EyelinkGetKey(el) % % el: eyelink default values, also stores % getkeytime (last time this function was used) % matlab version of eyelink supplied getkey() function % we can't call it getkey() as there is already a similar, % function in PsychToolbox % 02-06-01 fwc changed to accept el structure and tickcount value % which should hold the time at which getkeyforeyelink was used % last time. % key definitions are now set in 'initeyelinkdefaults.m' % 12-01-04 fwc adapted for use with OS X version of psychToolbox % replaced tickcount with el.getkeytime, that is % stored in el structure. Also max key repetition time is % now a parameter (el.getkeyrepeat) set in initeyelinkdefaults.m % there's now also a variant that tests % for key presses that only uses KbCheck % CharAvail fails on OS X so we only test for keypresses using keyIsDown % parameter from KbCheck function % 280606 fwc changed name to EyelinkGetKey % now actually returning char codes rather than true % characters % 270309 edf added function and modifier keys % 201213 lj added parameters for function modifyKey, for octave to get key responses from display side % excerpt from "exptsppt.h" % ******** KEY SCANNING ********/ % some useful keys returned by getkey() */ % These keys allow remote control of tracker during setup. */ % on non-DOS platforms, you should produce these codes and */ % all printable (0x20..0x7F) keys codes as well. */ % Return JUNK_KEY (not 0) if untranslatable key pressed. */ % TERMINATE_KEY can be to break out of EXPTSPPT loops. */ % Returns 0 if no key pressed */ % returns a single UINT16 integer code */ % for both standard and extended keys */ % Standard keys == ascii value. */ % MSBy is set for extended codes */ key=0; if nargin < 1 || ~isstruct(el) error( 'USAGE: [key, el]=EyelinkGetKey(el)' ); end if GetSecs-el.getkeytime0 % key=key(1); % take only first one in case more keys were pressed key=KbName(key(1)); % convert to a character, potential problem: KbName does not translate all keys to actual ascii characters. key=double(key(1)); % some keyNames have two characters (e.g. 8*); if key >=hex2dec('20') && key < hex2dec('7F') % only return printable chars (0x20..0x7F) modifyKey(el, keyCodes, key); return; end key=el.JUNK_KEY; % return code for untranslatable key return; end