Added setter for method val()
Improved check for special key pressed