Info

This question is closed. Reopen it to edit or answer.

How can I assign Keyboard keys to colours?

1 view (last 30 days)
Barbara Fiorani
Barbara Fiorani on 27 Oct 2020
Closed: Walter Roberson on 29 Oct 2020
Hi,
I need to assign colours to Kb names as I am creating a stroop task script with Psychtoolbox.
This is a part of my script:
WordList = {'blanket', 'garage', 'shampoo', 'handle', 'sofa', 'curtain', 'switch', 'bathroom', 'vase', 'hallway', 'duster', 'lounge'};
rgbColors = [1 0 0; 0 1 0; 0 0 1];
rng('shuffle')
%Improve portability of the code acorss operating systems
KbName('UnifyKeyNames');
% Specify key names of interest
activeKeys = [KbName('LeftArrow') KbName('RightArrow') KbName('UpArrow') KbName('Space')];
% Restrict the keys for keyboard input to the keys we want
RestrictKeysForKbCheck(activeKeys);
% Suppress echo to the command line for keypresses
ListenChar(2);
%Assign Kb to colours ??????????
How can i pair the Kb with colours? For example, if it appear a word in yellow the participant has to press Kb 'Uparrow' and so forth.

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!