Some background: browsers can be a bit protective of what kind of content can be copied to the clipboard programmatically. In order to keep the operation functional across all browsers, the copied content must come from a visible element in the DOM and the copy-to-clipboard action must happen as a direct result of a user action, like a mouse click or a keyboard event. In other words, you can't just execute a simple JavaScript function to copy content to the clipboard.
To get this working in Vaadin 14, here is an add-on which may help you: https://vaadin.com/directory/component/clipboardhelper/overview
Usage example:
Button button = new Button("click this button to copy some stuff to the clipboard");
ClipboardHelper clipboardHelper = new ClipboardHelper("some stuff", button);
add(clipboardHelper); // ClipboardHelper wraps the Button
The relevant sources can be found here:
https://github.com/OlliTietavainenVaadin/clipboardhelper/blob/master/src/main/resources/META-INF/resources/frontend/clipboard-helper.js