  We use a suitable version of the so-called "kernel trick" to devise
two-sample (homogeneity) tests, especially focussed on high-dimensional and
functional data. Our proposal entails a simplification related to the important
practical problem of selecting an appropriate kernel function. Specifically, we
apply a uniform variant of the kernel trick which involves the supremum within
a class of kernel-based distances. We obtain the asymptotic distribution (under
the null and alternative hypotheses) of the test statistic. The proofs rely on
empirical processes theory, combined with the delta method and Hadamard
(directional) differentiability techniques, and functional
Karhunen-Lo\`eve-type expansions of the underlying processes. This methodology
has some advantages over other standard approaches in the literature. We also
give some experimental insight into the performance of our proposal compared to
the original kernel-based approach \cite{Gretton2007} and the test based on
energy distances \cite{Szekely-Rizzo-2017}.
