Looks like the keep-active stuff was brought in with 156999d07911237327fe7ef4cd1e85cd6eb65048 as part of #559 

Think your refactor does exactly the same thing, though with enter/leave rather than down/up (which strikes me as being better ayway