KbName international / documentation

Hi,

one quick internationalization question: how does KbName handle international keyboard layouts? 
Using KbName I get response == 'y' whenever I press the Z key (whereas 'z' is echoed in the Command window) and vice versa on a German keyboard [OS X 10.6, Matlab 7.9.0.529 (R2009b), Psychtoolbox 3.0.8 beta rev. 1557 locally modified]. For a real-life example see listing below.

Is this expected? I think I noticed this before, but have coded around it. Nevertheless, to help avoid falling into the same trap again, it is worth mentioning this somewhere in the upper part of the KbName documentation (which btw now show funny characters ï¿½ after 'help KbName' in the command window and '�' in Terminal).

Best, Jochen



Same happens using the following function:

function response = collectResponse 

persistent keyIsDown t00 secs keyCode deltaSecs

responseSet = {'y', 'z'};
responseSetCode = KbName(responseSet);

keyIsDown = true;
while keyIsDown
  [keyIsDown, t00, keyCode, deltaSecs] = KbCheck();
end

done = false;
while ~done
  [keyIsDown, secs, keyCode, deltaSecs] = KbCheck();
  if keyIsDown && sum(keyCode)==1  % only a single key pressed
  if any(keyCode(responseSetCode))
  response = KbName(keyCode);
  done = true;
  end
  end
end
It may not be desired, but it is expected. If you "type KbName" you'll see that KbName is just a hard-coded lookup table from low-level system keycodes to character strings. The keycodes always correspond to US keyboard layouts and don't change if you change keyboard settings.

The funny characters are funny. They are there since the beginning, but nobody ever noticed. Seem to be some special formatting character keycodes that only made sense on MacOS-9.

-mario

--- In psychtoolbox@yahoogroups.com, Jochen Laubrock <laubrock@...> wrote:
>
> Hi,
>
> one quick internationalization question: how does KbName handle
> international keyboard layouts?
> Using KbName I get response == 'y' whenever I press the Z key (whereas
> 'z' is echoed in the Command window) and vice versa on a German
> keyboard [OS X 10.6, Matlab 7.9.0.529 (R2009b), Psychtoolbox 3.0.8
> beta rev. 1557 locally modified]. For a real-life example see listing
> below.
>
> Is this expected? I think I noticed this before, but have coded around
> it. Nevertheless, to help avoid falling into the same trap again, it
> is worth mentioning this somewhere in the upper part of the KbName
> documentation (which btw now show funny characters � after 'help
> KbName' in the command window and '�' in Terminal).
>
> Best, Jochen
>
>
>
> Same happens using the following function:
>
> function response = collectResponse
>
> persistent keyIsDown t00 secs keyCode deltaSecs
>
> responseSet = {'y', 'z'};
> responseSetCode = KbName(responseSet);
>
> keyIsDown = true;
> while keyIsDown
> [keyIsDown, t00, keyCode, deltaSecs] = KbCheck();
> end
>
> done = false;
> while ~done
> [keyIsDown, secs, keyCode, deltaSecs] = KbCheck();
> if keyIsDown && sum(keyCode)==1 % only a single key pressed
> if any(keyCode(responseSetCode))
> response = KbName(keyCode);
> done = true;
> end
> end
> end
>