% waitEsc.m
%
% Wait until Cogent 2000 captures an ESC-key event

%initialize Cogent 2000 resources
clear all;
config_keyboard;
config_display(0,1); %640x480 in window-mode
start_cogent;

%read C2K list of key codes
keymap=getkeymap;

%wait until ESC key pressed
%while echoing non-ESC events
[k,t,n]=waitkeydown(inf, keymap.Escape);

%notifications
disp(' ')
disp('ESCAPE key detected')
disp(['Key code (k) = ',num2str(k)])
disp(['Event time (t) = ',num2str(t),' msec'])
disp(['N of events (n) = ',num2str(n)])
disp(' ')
disp('Program terminated')
   
%close display window and reclaim C2K resources
stop_cogent;
