First of all, CommaKey is not a valid keyword in SenseTalk, so that would be why your first two scripts were not working. The keyword for a comma is just “comma” (which you would enter without the quotes). The third script (TypeText CommandKey, “,”) however, should be functional. You should be able to verify that it is typing what you expect by looking at the output panel (in the Run window).
Is it possible that you have a KeyDown earlier in your script that needs to be released (KeyUp)?
Another thing you could try if it’s still not working is to lengthen the amount of time that the key is pressed. You can do this by altering the KeyDownDelay and setting it to something like .1 (the default setting is likely .01 or .001). However, in order to restore it to its default after you no longer need it, I would recommend a script like this one:
put the keydowndelay into KDD --stores the current keydowndelay setting
set the keydowndelay to .1 --changes the value to slow the key press
typetext commandKey, ","
set the keydowndelay to KDD -- restores the original delay value
This way you know that it is set back to your default, whatever that happens to be.
A couple of suggestions:
Try using TypeText wherever possible instead of KeyDown and KeyUp; it is more direct and the modifier keys get released automatically. KeyDown and KeyUp can be useful if you need to do something else while a key is held down (such as a click).
Also, remember that eggPlant only does whatever a user would do, and so if the user would not type something, then eggPlant should not have to type it either. I say this particularly in reference to your use of the Return key in your first and last scripts. This use of Return is not only unnecessary but is actually being modified by the CommandKey. It is in effect a CommandKey Return, not just a Return.
It looks like you are also adding “Key” in places where it is not necessary (examples: “commaKey” and “RKey” should be “comma” and “R”). In the case of “commakey”, it is causing the SUT to type “c,o,m,m,a,k,e,y” instead of hitting the comma key. This is good to keep in mind as it could cause complications.
For instance, in a word document on my SUT when I run the command
typeText commandKey, RKey
the Edit menu is selected, because of the “e” in “Key”, since in this case command R and command K do nothing.
And so, you could also try using “comma”, like this, since “comma” by itself is a valid keyword:
typeText commandKey, comma
If you’re still having trouble, could you specify what context this command is in, that might give clues to why it may not be working?