In the example code, I use a KeyListener to capture all key events. Once a key event gets captured, it simply prints out the corresponding key code to the standard output. As a result, once clicking F1 you should see this output gets printed out:
In test code if I use other keys such as SWT.DEL or other characters as 'a', '5' ... as the test runs, same key code get printed out as I click. However, I did not receive any output if I use SWT.F1-12. I believe the function key F1 did not get simulated correctly.