Ubuntu 20.04, sometimes after boot the keyboard and trackpad don't work (but the external mouse does) until reboot

It is not often that I see this issue reported with fresh installations, and rarely is it something that happens sometimes, but here are some possible solutions based on the most common causes of this issue:

1 — Install the Hardware Enablement Stack

Your notebook is certified by Canonical to work with Ubuntu 20.04, so you may be able to install the Hardware Enablement Stack, which provides newer kernels and better X support for the LTS releases. This is one of the first things I do when setting up a notebook with an LTS.

Here is how you do it:

  1. Open Terminal (if it's not already open)
  2. Verify that your machine is certified by Canonical:
    ubuntu-drivers list-oem 
    
    There will probably be no result, which is a good thing.
  3. Install the Hardware Enablement stack:
    sudo apt install --install-recommends linux-generic-hwe-20.04 
    
  4. Reboot

If your keyboard and mouse are working properly, then the input problems may be a thing of the past. If not, you may need to Install the X11 Input Drivers ...

2 — Install the X11 Input Drivers

There are occasions when there will be a conflict between the Linux kernel and the X11 input drivers. This can usually be resolved by installing the xserver-xorg-input-all package:

  1. Open Terminal (if it's not already open)
  2. Install the input drivers:
    sudo apt install xserver-xorg-input-all
    
  3. Reboot (Optional)

In the event the keyboard continues to appear unresponsive, this could be due to interference from the Accessibility settings ...

3 — Check the Accessibility Settings

On occasion I have seen people lose access to their keyboard (but not the trackpoint/touchpad/mouse) due to an accidental triggering of the Accessibility settings. If you do not wish to use the Accessibility features, then they can be disabled. If you use some of the Accessibility features, then it would be good to double-check their efficacy:

  1. Open the Settings application: Settings from the Menu
  2. Select "Accessibility" from the left-side menu: Settings - Accessibility
  3. Find the "Typing" section: Accessibility - Typing Click on the "Typing Assist (AccessX)" option.
  4. Confirm your settings: Typing Assist OptionsNotes:
    • "Enable by Keyboard" will allow accessibility options to be enabled via the shortcuts defined in the "Keyboard Shortcuts" section of Settings.
    • "Sticky Keys" allow you to type keyboard shortcuts one key at a time rather than having to hold down all of the keys at once. For example, rather than Ctrl+C to copy, it would be Ctrl ... C. Any length of time may pass between the keypresses, which can result in what appears to be an unresponsive key stroke.
    • "Slow Keys" will require a key to be pressed for a certain period of time before it appears on the screen. If it is set to "Long", then a keypress will not be registered until a key is held down for several seconds. For people who can touch-type 100+ words a minute, this can result in what appears to be a non-functional keyboard. If you use this feature, be sure the register time is configured to your liking.
    • "Bounce Keys" will reject duplicate keypresses within a certain period of time. Typing a word like "difficult" or "tool" with a typical typing speed of 90 words a minute would result in a missing F and O respectively. If you use this feature, be sure the acceptance delay is configured to your liking.

So long as you are not experiencing hardware failure, one (or more) of these options should ensure you have a properly functional keyboard every time your notebook boots.