There's nothing special: assuming you've defined a bar family of keys
\NewEnviron{foo}[1]{%
\setkeys{bar}{#1}%
do something with \BODY
}
or
\NewEnviron{foo}[1][]{%
\setkeys{bar}{#1}%
do something with \BODY
}
will allow the syntax
\begin{foo}{key1=value1,key2=value2}
text
\end{foo}
or
\begin{foo}[key1=value1,key2=value2]
text
\end{foo}
respectively. Which one to prefer depends on many factors: if the user has to supply at least a key-value pair, then the first form is recommended.
I've used \setkeys, as I don't know how keycommand works (it should be very similar, anyway).
\setkeys, because i found the syntax ofkeycommandeasier. So, I have to read how to use\setkeys. From which package is it ? – Loic Rosnay Mar 13 '12 at 10:14keycommandloadsxkeyval, which is an extension ofkeyval. I recommend looking at the documentation ofkeyvalwhich is quite neat about defining and setting keys. – egreg Mar 13 '12 at 10:22