added optional parameter to use the click button instead of key