@Tim's answer shows how inverse transform sampling can be adapted for truncated distributions, freeing run-time of dependency on the threshold $k$. Further efficiencies can be got by avoiding costly numerical evaluation of the beta quantile function & using inverse transform sampling as part of rejection sampling.
The density function of a beta distribution with shape parameters $\alpha$ & $\beta$ doubly truncated at $k_1<k_2$ (for a little more generality) is
$$ f(x) = \frac{x^{(\alpha-1)}(1-x)^{(\beta-1)}}{\operatorname{B}(k2, \alpha, \beta) - \operatorname{B}(k_1, \alpha, \beta)}$$
Take any monotonically increasing part of the density between $x_\mathrm{L}$ & $x_\mathrm{U}$: for $\alpha,\beta>1$ it's log-concave, so you can envelop it with an exponential function drawn at a tangent to any point along it:
$$ g(x) = c \cdot \lambda \mathrm{e}^{-\lambda (x-x_\mathrm{L})}$$
Find $\lambda$ by setting the gradients of the log densities equal
$$ -\lambda = \frac{a-1}{x} - \frac{b-1}{1-x}$$
& find $c$ by working out how much the exponential density needs to be scaled up to meet the density at that point
$$ c = \frac{f(x)}{\lambda\mathrm{e}^{-\lambda(x-x_\mathrm{L})}} $$
The best envelope for rejection sampling is the one with the smallest area below it. The area is
$$ A = c \cdot (1 - \mathrm{e}^{-\lambda(x_\mathrm{U}-x_\mathrm{L})})$$
Substituting expressions in $x$ for $\lambda$ & $c$, & dropping constant factors gives
$$\begin{align}
Q(x)= & \frac{x^a (1-x)^b}{(a+b-2)x - a+1} \cdot\\
& \left[\exp\left(\frac{(b-1)(x-x_L)}{1-x} + \frac{x_L (a-1)}{x} - (a-1)\right) - \right.\\
& \left. \exp\left(\frac{(b-1)(x-x_U)}{1-x} + \frac{x_U(a-1)}{x} - (a-1)\right)\right]\\
\end{align}$$
Writing the derivative $ \frac{\mathrm{d} Q}{\mathrm{d} x}$ is left as an exercise for readers or their computers. Any root-finding algorithm can then be used to find the $x$ for which $\frac{\mathrm{d} Q}{\mathrm{d} x} = 0$.
The same goes, mutatis mutandis, for monotonically decreasing parts of the density. So the truncated beta distribution can be quite neatly enveloped by two exponential functions, say, one from $k_1$ to the mode & one from the mode to $k_2$, ready for rejection sampling. (For a truncated uniform random variable $U$, $\frac{- \log(1-U)}{\lambda}$ has a truncated exponential distribution with rate parameter $\lambda$.)
The beauty of this approach is that all the hard work's in the set up. Once the envelope function's defined, the normalizing constant for the truncated beta density calculated, all that's left is to generate uniform random variates, & perform on them a few simple arithmetical operations, logs & powers, & comparisons. Tightening the envelope function—with horizontal lines or more exponential curves—can of course reduce the number of rejections.