I think LaTeX packages rarely use macros as key names. And some users expect macros inside the keyval input will be expanded recursively first. But l3keys in expl3 doesn't provide this functionality at this time. So it is a job of package writers. I can think of one way to do this. But it may be a little slow. Therefore I ask this question in hope of finding the best solution.
Note: only macros surrounded by commas are expanded inside keyval input.
\documentclass{article}
\ExplSyntaxOn
\keys_define:nn { test }
{
key1 .code:n = \tl_to_str:n {#1},
key2 .code:n = \tl_to_str:n {#1},
key3 .code:n = \tl_to_str:n {#1},
key4 .code:n = \tl_to_str:n {#1},
key5 .code:n = \tl_to_str:n {#1},
key6 .code:n = \tl_to_str:n {#1},
}
\NewDocumentCommand \mycommand {m}
{
\keys_set:nn { test } { #1 }
}
\ExplSyntaxOff
\begin{document}
\mycommand{key1=val1,key2=val2,key3=val3,key4=val4,key5=val5,key6=val6}
\def\mymacroa{key3=val3,key4=val4}
\mycommand{key1=val1,key2=val2,\mymacroa,key5=val5,key6=val6} % error
\def\mymacrob{key2=val2,\mymacroa,key5=val5}
\mycommand{key1=val1,\mymacrob,key6=val6} % error
\end{document}


f-expansion in the code, which would allow this. Are these plans cancelled? – Skillmon Jun 19 '22 at 06:18\usepackage)? Then it will benefit more packages. – L.J.R. Jun 19 '22 at 08:07\begin{advertisement}not related tol3keys/ltkeys, but my ownexpkvhas something "in the pipeline" as well, which would allow something similar with a dedicated syntax (somewhat likeexpl3's\exp_args:...inside the key=value interface).\end{advertisement}– Skillmon Jun 19 '22 at 08:15\keyval_parse:nnN, but like I said, not fully agreed yet – Joseph Wright Jun 19 '22 at 08:18=. The further might allow macros yielding more key=value-pairs.) – Ulrich Diez Jun 19 '22 at 09:29f-expand as a first step, before splitting. Note that keys with=should already be possible by{key=name} = {key=value}. – Skillmon Jun 19 '22 at 10:23