JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<canvas id="canvas" width="450" height="450"></canvas>
<ul id="log">
    <li>List of keys:</li>
</ul>
<!-- Jquery -->

JavaScript

$(document).ready(function(){
	//Canvas stuff
	var mininter = 35;
	var defal = 100;
	var interval = defal;
	var canvas = $("#canvas")[0];
	var ctx = canvas.getContext("2d");
	var w = $("#canvas").width();
	var h = $("#canvas").height();
	var img= new Image() 

	var img = new Image();
	img.src = 'http://s1306.hizliresim.com/1b/f/p3dlm.png';
	img.width = 25;
	img.height = 25;
	ctx.drawImage(img, 150, 150, 25, 25);
	ctx.fill();
	
	var cw = 5;
	var wid = 25;
	var d;
	var food;
	var score;
	
	//ilk topu yaratalım
	var snake_array; 
	function init()
	{
		d = "right"; //default direction
		create_snake();
		create_food();
		
		// 60ms
		if(typeof game_loop != "undefined") clearInterval(game_loop);
		game_loop = setInterval(paint, 60);
	}
	init();
	
	function create_snake()
	{
		var length = 1; 
		snake_array = []; 
		for(var i = length-1; i>=0; i--)
		{
			snake_array.push({x: i, y:0});
		}
	}
	
	//İkinci topu yap
	function create_food()
	{
		food = {
			x: Math.round(Math.random()*(w-cw)/cw), 
			y: Math.round(Math.random()*(h-cw)/cw), 
		};
	}
	
	//Boyama
	function paint()
	{
		
		ctx.fillStyle = "white";
		ctx.fillRect(0, 0, w, h);
		ctx.strokeStyle = "black";
		ctx.strokeRect(0, 0, w, h);
		
		var nx = snake_array[0].x;
		var ny = snake_array[0].y;
		
		
		var fx = food.x;
		var fy = food.y;
		
		//Kendi yürüyüşümüz
		if(d == "right"){nx++;}
		else if(d == "left") nx--;
		else if(d == "up") ny--;
		else if(d == "down") ny++;
		else if(d == "upleft"){ nx--; ny--;}
		else if(d == "upright"){ nx++; ny--;}
		else if(d == "downright"){ nx++; ny++;}
		else if(d == "downleft"){ nx--; ny++;}
		else if(d == "stop"){ nx == nx; ny == ny;}
		
		//Ekrandan çıkma
		if(nx == -1){
		
			nx = w/cw;
		
		}else if(nx == w/cw)
		{
			nx = 0;
		}else if(ny == -1){
			ny = h/cw;
		}else if(ny == h/cw){
			ny = 0;
		}
		
		if(food.x <= -1){
		
		
			food.x = w/cw;
		
		}else if(food.x >= w/cw)
		{
			food.x = 0;
		}else if(food.y <= -1){
			food.y = h/cw;
		}else if(food.y >=...