Indeed, i wrote this from memory and that's wrong...
It is: position.keySelected(idx);
and in general the syntax to read a key something is myProperty.keyXxx(idx);
and not what i wrote. Sorry.
But well, if you have access to the table of methods in the scripting guide... they are all there.
Xavier.