I hadn't considered that. If it's being called in different places, it's probably best to leave the conditional checking to the caller, as each caller will probably have a different condition for calling the function. This way you have greater flexibility in how you use bar() and leave its implementation clean.
Which is easier to maintain? Which keeps the code more generic and re-usable?
Well, it depends I think. For a function like sayHello(), you keep that modular by letting it execute its task and nothing else. The caller can take care of when it's called. However, for a function like handleKeyInput(), I would think it's best to call it every frame regardless of whether or not there was any input from the user and let it do its own key checking. This would be easier to maintain as you have a neat reusable package that can be applied anywhere you want to handle user key input. At least that's how I see it. Am I thinking along the right lines?