I am trying to understand how to construct macros with pgfkeys and found the following solution very useful but there is something I would like to do
I have made a very minimal example below. What I would like is to have a key that doesn't take a value but something happens whether the key is there or not. In other words, I would like a syntax like the parts below that are commented out. I assume this is possible since in tikz we can create, for example, node[draw, circle, fill=red].
So how can we create keys that take no values?
(I suppose that even my example below can be even done without ifthen too)
\documentclass{article}
\usepackage{ifthen}
\usepackage{pgfkeys}
\pgfkeys{
/display/.is family, /display,
show/.estore in = \myShow,
}
\newcommand\macroname[2][]{%
\pgfkeys{/display, #1}%
\ifthenelse{{\equal{\myShow}{once}}}{#2}
\ifthenelse{{\equal{\myShow}{twice}}}{#2#2}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\macroname[show=once]{input}
\macroname[show=twice]{input}
% \macroname[once]{input}
%
% \macroname[twice]{input}
\end{document}
PLAN B
Following from the comment of percusse I had another attempt at understanding the manual's Key handler /.is if. I got something to work, but not everything to how I expected. The MWE below shows three instances of the macro. Why when one uses the key once I still need to set it to true for it to work?
\documentclass{article}
\usepackage{pgfkeys}
\newif\ifdisplayonce
\pgfkeys{/once/.is if=displayonce}
\pgfkeys{/once/.default=false}
\newcommand\macronameb[2][]{%
\pgfkeys{/once, #1}
\ifdisplayonce
#2
\else
#2#2
\fi
}
\begin{document}
\macronameb{input1}
\macronameb[once=true]{input2}
\macronameb[once]{input3}
\end{document}


/.is if– percusse Nov 17 '17 at 20:11default(orinitial, since these are often confiused withpgfkeys) to set a key with an.is ifhandler. Instead, you have to set it "by hand" using\displayoncetrueor\displayoncefalse. – Nov 17 '17 at 21:53pgfkeys, I just read the code and thought I found the problem. However @Andrew wrote why I was (kind of) wrong :-) Thanks! – Tobi Nov 18 '17 at 10:03