Since Y is metrizable, you can also prove it via convergent sequences.
For notational convenience I’ll write $Y=\omega\times[0,1]$. A sequence $\left\langle\langle n_k,x_k\rangle:n\in\omega \right\rangle$ in $Y$ converges to $\langle n,x\rangle$ iff $\langle x_k:k\in\omega\rangle\to x$ in $[0,1]$ and $n_k=n$ for all sufficiently large $k$, so a sequence $\Big\langle\big\langle\langle n_k,x_k\rangle,\langle m_k,y_k\rangle\big\rangle:k\in\omega\Big\rangle$ converges to $\big\langle\langle n,x\rangle,\langle m,y\rangle\big\rangle$ in $Y^2$ iff $\langle x_k:k\in\omega\rangle\to x$ in $[0,1]$, $\langle y_k:k\in\omega\rangle\to y$ in $[0,1]$, and $n_k=n$ and $m_k=m$ for all sufficiently large $k$. If $n\ne m$, the sequence $\Big\langle f\big(\langle n_k,x_k\rangle,\langle m_k,y_k\rangle\big):k\in\omega\Big\rangle$ is eventually constant with value $\frac1n+\frac1m$, and if $n=m$ it’s eventually just the sequence of $|x_k-y_k|$, which certainly converges to $|x-y|$. Thus, $f$ preserves convergent sequences and is therefore continuous.