Render key and value of a field
Here is how you can get the list field key and value

function themename_preprocess_field(&amp;$variables, $hook) {

    if ($variables['field_name'] == 'field_test') {

        foreach ($variables['items'] as $key =&gt; $item) {
            $list_field_value = $item['content']['#markup'];
            $list_field_key = $variables['element']['#items'][$key]-&gt;getString();
        }

    }

}


Note: replace field_test with the actual field machine name, do not replace field_name.