Using a candle as a time-release is a well-known method. See, for example, this post.
What do you think might go wrong here?
- the candle falls down and starts the fire
- the string will not burn
- you may fell off the bed and not be able to get back to pick up the keys or the knife
- see the video below