The code uses a timer to time the periods between "dots" and "dashes". If the button press is shorter than a threshold value then the program generates a "dot", otherwise it generates a "dash". If the timing is not to your liking then alter the time threshold value in the source code.
See the files section to download the Arduino source code.