Another method:
Say there are $\binom{r}{2}$ pairs of keys. Each has collision with probability $\sum_{i\in[k]} p_i^2$ where $[k] = \{1,\dots,k\}$.
Thus the expected number of collisions between pairs is $\binom{r}{2} \sum_{i\in[k]} p_i^2$.
But this overcounts as there may be collisions with sets of 3, which are repeat-counted. This has probability $\sum_{i\in[k]} p_i^3$ and there are $\binom{r}{3}$ many triples. Thus expected number of collisions with sets of 3 is $\binom{r}{3} \sum_{i\in[k]} p_i^3$.
In general, the expected number of collisions , with sets of size $j$ is $$\binom{r}{j} \sum_{i\in[k]} p_i^j$$
Now using the inclusion-exclusion principle, the total expected number of collisions is $$\binom{r}{2} \sum_{i\in[k]} p_i^2 - \binom{r}{3} \sum_{i\in[k]} p_i^3 + \dots + (-1)^r \binom{r}{r} \sum_{i\in[k]} p_i^r$$
But this can be simplified further by adding and subtracting $\binom{r}{0}\sum_{i\in[k]} (p_i^0) - \binom{r}{1}(\sum_{i\in[k]} p_i) = k-r$.
Then the above expression equals:
\begin{align*}
&\binom{r}{2} \sum_{i\in[k]} p_i^2 - \binom{r}{3} \sum_{i\in[k]} p_i^3 + \dots + (-1)^r \binom{r}{r} \sum_{i\in[k]} p_i^r\\
&= - \left(k - r\right) + \left(\binom{r}{0} \sum_{i\in[k]} p_i^0 - \binom{r}{1} \sum_{i\in[k]} p_i + \binom{r}{2} \sum_{i\in[k]} p_i^2 - \dots + (-1)^r \binom{r}{r} \sum_{i\in[k]} p_i^r\right)\\
&= r-k + \sum_{i\in[k]}\left(\sum_{j=0}^r (-1)^j \binom{r}{j}p_i^j\right)\\
&= r-k + \sum_{i\in[k]}\left(1-p_i\right)^r
\end{align*}