When there is no sheriff in any county, it is the duty of the coroner to exercise all the powers and duties of the sheriff of his county until a sheriff is appointed or elected and qualified; and when the sheriff for any cause is committed to the jail of his county, the coroner shall be keeper of such jail during the time the sheriff remains a prisoner.