Micro-optimizations, bug fixes

- Declare all vars at the beginning of the current scope, it allows to minify the script better (~-100bytes), small chance to increase perfomance;
- Cache some values;
- Chain some functions;
- On click on opened dropdown we close it, on click on another dropdown, we close current dropdown and open another - similiar behaviour with original <select>
- ~~Remove redundant if conditions in switch~~
- Better keyCode detection