Customized action according to keyboard activity, modified from syndaemon.