Microwave resonators with a keyhole profile (KHRs) operating in the C band and the X band are designed and studied in numerical simulations and experiments. KHR structures concentrate a microwave magnetic field in a subwavelength volume, while suppressing microwave electric fields. This microwave magnetic field is focused at a finite working distance from KHR metal structures, allowing convenient optical excitation of the sample in both the Faraday geometry and the Voigt geometry. By means of room-temperature optically detected electron spin resonance on $\mathrm{Si}\mathrm{C}$ quantum defects, the conversion factor ${B}_{1}{P}_{\mathrm{MW}}^{\ensuremath{-}1/2}$ for conversion of microwave power into a microwave magnetic field is measured to be approximately $1.0\ifmmode\times\else\texttimes\fi{}{10}^{\ensuremath{-}3}\phantom{\rule{0.2em}{0ex}}\mathrm{T}\phantom{\rule{0.1em}{0ex}}{\mathrm{W}}^{\ensuremath{-}1/2}$ at a frequency of approximately 7 GHz and a working distance of approximately 0.5 mm from the KHR structure. Numerical simulations match the experimental observations, and an example model code for use with the finite-element-method program elmer is provided. The KHR structures are most promising for fast coherent electron-spin control in solid-state spin qubits, where a large microwave magnetic field needs to be achieved with simultaneous suppression of microwave heating and electric fields, while permitting efficient optical spin initialization and readout.