How do I retrieve the query parameters from a path?
The problem was the block was cached.  See Clive's comment:

public function build() {
  $test = \Drupal::request()-&gt;query-&gt;get('keys');
  return array(
    '#markup' =&gt; $test,
    '#cache' =&gt; array(
      'contexts' =&gt; array(
        'url.query_args:keys',
      ),
    ),
  );
}