I'll do it for the case where the man has $k$ keys and gets the correct key on the $j$th try. Essentially, we're trying to find

$$P(\text{Drunk|$j ^{th}$ attempt successful})$$
By Bayes' Theorem,

$$P(\text{Drunk|$j ^{th}$ attempt successful}) = \frac{P(\text{Drunk $\cap$ $j ^{th}$ attempt successful})}{P(\text{$j ^{th}$ attempt successful})}$$

Let's find the denominator first. We can do this with the Law of Total Probability
$$P(\text{$j ^{th}$ attempt successful}) = P(\text{$j ^{th}$ attempt successful|Drunk})P(\text{Drunk}) + P(\text{$j ^{th}$ attempt successful|Sober})P(\text{Sober})$$

We are told that he comes home drunk about half the time, so $P(\text{Drunk}) = \frac{1}{2}$ and $P(\text{Sober}) = \frac{1}{2}$.

We also know that when drunk he has the chance to repeat keys and when sober he tries the keys without repetition, so
$$P(\text{$j ^{th}$ attempt successful|Drunk}) = P(\text{$j$ attempts with repetition}) \\ = \left( \frac{k-1}{k}\right)^{j-1}\frac{1}{k} \\ (\text{Because we get the wrong key $j-1$ times and then the right key}) $$

$$P(\text{$j ^{th}$ attempt successful|Sober}) = P(\text{$j$ attempts without repetition}) = \frac{1}{k}$$

Putting this together:$$P(\text{$j ^{th}$ attempt successful}) = \left( \left( \frac{k-1}{k}\right)^{j-1}\frac{1}{k} \right)\left( \frac{1}{2} \right) + \left( \frac{1}{k} \right) \left( \frac{1}{2} \right) \\ = \left( \frac{1}{2} \right)\left[ \left( \frac{k-1}{k}\right)^{j-1}\frac{1}{k} + \left( \frac{1}{k} \right)\right]$$

Now all that's left is the numerator which we've honestly already done a lot of the work for $$P(\text{Drunk $\cap$ $j ^{th}$ attempt successful}) = P(\text{$j ^{th}$ attempt successful|Drunk})P(\text{Drunk}) \\ \text{(This is the first term in our law of total probability equation)} \\ = \left( \frac{1}{2} \right) \left( \frac{k-1}{k} \right)^{j-1}\frac{1}{k} $$

Altogether now we have:

$$P(\text{Drunk|$j ^{th}$ attempt successful}) = \frac {{\left( \frac{1}{2} \right) \left( \frac{k-1}{k} \right)^{j-1}\frac{1}{k}}}{\left( \frac{1}{2} \right)\left[ \left( \frac{k-1}{k}\right)^{j-1}\frac{1}{k} + \left( \frac{1}{k} \right)\right]} \\ = \frac{\left( \frac{k -1 }{k} \right)^{j-1}}{1 + \left( \frac{k -1 }{k} \right)^{j-1} }$$

If you substitute in the numbers you have, you should end up with $\frac{16}{41} = \overline{.39024}$