Normally, \pgfkeys{<key path>/.code=...} internally defines two keys <full key path>/.@cmd and <full key path>/.@body, hence you can use
\documentclass{article}
\usepackage{tikz}
\pgfqkeys{/pgf}{test/.code={TEST}}
\begin{document}
\pgfkeysifdefined{/pgf/test/.@cmd}{TRUE}{FALSE} % output "TRUE"
\pgfkeysifdefined{/pgf/test/.@body}{TRUE}{FALSE} % output "TRUE"
\pgfkeys{/pgf/test}
\end{document}
There is a short introduction to <key>/.@cmd in the pgf manual, sec. 88.3.3.
More Notes
\pgfkeysifdefined{<key>}{<true>}{<false>} tests if an internal command \pgfk@<key> is defined, it cannot be used to test if a <key> is defined by handler .code.
- On the one hand, keys defined by some handlers are not distinguishable. For example,
.code and .ecode.
- On the other hand, keys defined by some other (kinds of) handlers are distinguishable. For example, keys defined by
.(e)code and .(e)code 2 args can be distinguished by the argument specification part of their corresponding \pgfk@<key>/.code commands.