It's a bit more complicated:
A code key (/path/some key/.code=) executes the code between = and , with the given value as parameter (#1). Normally it has no value, so \pgfkeysvalueof{/path/some key} will give out nothing (see 7 and 8). A value key can be set with another key/.initial=initial value. It will be given out with \pgfkeysvalueof{/path/another key} (see 9) or with \pgfkeys{/path/another key} (see 3). But \pgfkeys{/path/another key=another value} will just set the value, overwriting the old one, and give out nothing (see 6).
A code key can have a default value (path/some key/.default=), which will be used, if no value is given (see 2). This default will not be changed, if the key is called with a value given.
With \pgfkeyssetvalue{/path/some key}{value} a value can be assigned to the code key (see 10). After that, \pgfkeysvalueof{/path/some key} will deliver this value (see 11). But \pgfkeys{/path/some key=something} will still execute the code with the given value as parameter. Nevertheless, this will not change the value set with \pgfkeyssetvalue (see 13).
A more common example for a code key is color d (see 14) in the code below.
Here some example code:
\documentclass[a4paper]{article}
\usepackage{pgfkeys}
\usepackage{xcolor}
\pgfkeys{%
/path/.cd,
color a/.code=#1,
color b/.code=#1,
color b/.default=red,
color c/.initial=blue,
color d/.code={\color{#1}},
}
\parindent0pt\parskip1ex
\begin{document}
\begin{enumerate}
\item \verb|\pgfkeys{/path/color a}|: \pgfkeys{/path/color a}\\
(executes given code with empty parameter)
\item \verb|\pgfkeys{/path/color b}|: \pgfkeys{/path/color b}\\
(executes given code with default value as parameter)
\item \verb|\pgfkeys{/path/color c}|: \pgfkeys{/path/color c}\\
(gives out initial value)
\item \verb|\pgfkeys{/path/color a=yellow}|: \pgfkeys{/path/color a=yellow}\\
(executes given code with ``yellow'' as parameter)
\item \verb|\pgfkeys{/path/color b=green}|: \pgfkeys{/path/color b=green}\\
(executes given code with ``green'' as parameter)
\item \verb|\pgfkeys{/path/color c=cyan}|: \pgfkeys{/path/color c=cyan}\\
(just sets a new value)
\item \verb|\pgfkeysvalueof{/path/color a}|: \pgfkeysvalueof{/path/color a}\\
(key has no value)
\item \verb|\pgfkeysvalueof{/path/color b}|: \pgfkeysvalueof{/path/color b}\\
(key has no value)
\item \verb|\pgfkeysvalueof{/path/color c}|: \pgfkeysvalueof{/path/color c}\\
(gives out the last value stored)
\item \verb|\pgfkeyssetvalue{/path/color a}{blue}|: \pgfkeyssetvalue{/path/color a}{blue}\\
(sets a value)
\item \verb|\pgfkeysvalueof{/path/color a}|: \pgfkeysvalueof{/path/color a}\\
(now key has a value)
\item \verb|\pgfkeys{/path/color a=yellow}|: \pgfkeys{/path/color a=yellow}\\
(still executes given code with ``yellow'' as parameter)
\item \verb|\pgfkeysvalueof{/path/color a}|: \pgfkeysvalueof{/path/color a}\\
(but the value has not changed)
\item \verb|\pgfkeys{/path/color d=magenta}|: \pgfkeys{/path/color d=magenta}\\
(executes given code, which switches to the given color)
\end{enumerate}
\end{document}
And its result:

color bis a code key, it gets executeted in item 5. But as a normal code key it has no value. The valuegreenis used as parameter for the execution (see result of 5), but not stored anywhere. – Mike May 21 '18 at 20:20\pgfkeysvalueofneeds a full path for the key, starting with/. So\color{\pgfkeysvalueof{/color}}works. – Mike May 23 '18 at 19:54