Synchrotron X-ray emission in young supernova remnants (SNRs) is a powerful diagnostic tool to study the population of high-energy electrons accelerated at the shock front and the acceleration process. We performed a spatially resolved spectral analysis of NuSTAR and XMM-Newton observations of the young Kepler's SNR, aiming to study in detail its nonthermal emission in hard X-rays. We selected a set of regions all around the rim of the shell and extracted the corresponding spectra. The spectra were analyzed by adopting a model of synchrotron radiation in the loss-limited regime, to constrain the dependence of the cutoff energy of the synchrotron radiation on the shock velocity. We identify two different regimes of particle acceleration, characterized by different Bohm factors. In the north, where the shock interacts with a dense circumstellar medium (CSM), we found a more efficient acceleration than in the south, where the shock velocity is higher and there are no signs of shock interaction with the dense CSM. Our results suggest an enhanced efficiency of the acceleration process in regions where the shock-CSM interaction generates an amplified and turbulent magnetic field. By combining hard X-ray spectra with radio and γ-ray observations of Kepler's SNR, we modeled the spectral energy distribution. In the light of our results we propose that the observed γ-ray emission is mainly hadronic and originates in the northern part of the shell.