You can easily create a morse code transmitter with just a couple of blocks to check if a button is pressed and play a tone.
First you need to set leg 0 into music mode.
Click the blue cog on the start block and tick the checkbox next to leg 0 input/output, click the cog again to close this window.
Now click the leg 0 drop down that has appeared on the start block and select music (PWM) output.
From the Music menu, drag in a start tone block and snap it below your start block.
From the Sprite menu, drag in a draw sprite block and snap it below your start tone block.
Also from the Sprite menu, drag in a build sprite block and snap it to your draw sprite block. Tick all the boxes on your build sprite block.
You will want your program to loop so it will continuously respond to button presses.
If you ran your program now, it would beep forever. We want it to sleep (turn off the sound and LEDs) when the buttons are not pressed.
From the Loops menu, drag in another repeat while loop and snap it inside your first repeat while loop.
From the Logic menu, drag in an and block and snap it to your inner repeat while loop. Click its drop-down arrow and select or.
From the Inputs/Outputs menu, drag in two button A pressed blocks and snap them into the gaps of your or block.
From the Basics menu, drag in a sleep until button changes block and snap it inside your outer repeat while loop, below your inner repeat while loop.
Click the Play button to run your code. Click the buttons on the CodeBug emulator to flash the LEDs and tone.
Click the Download button to download your program and then load it onto your CodeBug.