Adding action to textarea I am hoping that this enquiry will be a easy one for someone to help shed some light on... I know that in order to create a textarea in Drupal 8 the following code can be used (e.g. render array)

$the_textarea=array(
        '#type' =&gt; 'textarea',
        '#required' =&gt; FALSE,
        '#ajax' =&gt; array (
            // Function to call when event on form element triggered.
            'callback' =&gt; array($this-&gt;componentCallbackObject,$this-&gt;componentCallbackFunction),
            'event' =&gt; $this-&gt;componentEvent,
        ),
    );


In the above code, a callback is defined using ajax ... this has the result of the code requiring the client to communicate with the server, which then sends back instructions to the client side using ajax... Is there away to get a component to execute some javascript (where the javascript would be loaded when the page in question, first loads) and when either the upkey, downkey or onchange event is triggered for the textarea the javascript, which would already be available to the client would be executed.  

The main point here is that the client wouldn't need to communicate with the server, just with the javascript which is loaded when the page first loads e.g. without having to callback to the server and then wait for the server to send back the information.
The technique you need is easy, the full details can be complicated (depending on exactly what you want the JS to do). You can attach a custom JavaScript file from without your module in three steps:


Create the JS file.
Define a library.
Attach the library to the form element.


The JavaScript should typically live in a folder named js at the root of your module: js/my-great-jscode.js.

To create your library add a [module_name].libraries.yml file to the root of your custom module.  In there define the library:

my-library:
  version: 1.x
  js:
    js/my-great-jscode.js: {}


Then to attach the code to your form element you add #attached =&gt; library to the render array. 

$the_textarea=array(
  '#type' =&gt; 'textarea',
  '#required' =&gt; FALSE,
  '#ajax' =&gt; array (
  // Function to call when event on form element triggered.
  'callback' =&gt; array($this-&gt;componentCallbackObject,$this-&gt;componentCallbackFunction),
  'event' =&gt; $this-&gt;componentEvent,
  ),
  '#attached' =&gt; [
    'library' =&gt; [
      'my-module/my-library',
    ],
  ],
);


There is more detail in Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 module on Drupal.org