scd: Factor out a function to check keyidstr.