The altkey property is used to show whether ALT key is pressed or not when key event was triggered.ExampleYou can try to run the following code to learn how to implement altKey property in JavaScript. Press any key function funcAltKey(event) { var val = document.getElementById("res"); if (event.altKey) { val.innerHTML = "ALT key: Pressed"; } else { val.innerHTML = "ALT key: NOT Pressed"; } }
Use the copyWithin() method in JavaScript to copy array elements. You can set the index from/to where (index) the elements are copied. The following are the elements supported by JavaScript.target − The position of the index from where the elements is to be copied.begin − The index to start copying the element. This is an optional parameter.end − The index to end copying the element. This is an optional parameter.ExampleYou can try to run the following code to learn how to work with copyWithin() method in JavaScript. var num ... Read More
This example demonstrates how to enable or disable the GPS programmatically on Kotlin.Step 1 − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.Step 2 &minsu; Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.content.Context import android.content.Intent import android.location.LocationManager import android.os.Bundle import android.provider.Settings import android.view.View import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { private lateinit var context: Context var intent1: Intent? = null lateinit var textView: TextView ... Read More
This example demonstrates how to create a WebView in an Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following dependency to build.gradle(Module:app)implementation 'com.squareup.picasso:picasso:2.5.2'Step 4 − Add the following code to src/MainActivity.ktExampleimport android.os.Bundle import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity import com.squareup.picasso.Picasso class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) ... Read More
This example demonstrates how to Create a listView with a checkBox in Kotlin.Step 1 − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktExampleimport android.view.View import android.widget.AdapterView.OnItemClickListener import android.widget.ListView import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() { private var dataModel: ArrayList? = null private lateinit var listView: ListView private lateinit var adapter: CustomAdapter override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) ... Read More
This example demonstrates how to create a WebView in an Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.Example Step 3 − Add the following code to src/MainActivity.ktExampleimport android.os.Bundle import android.webkit.WebView import android.webkit.WebViewClient import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { private val webView: WebView? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" val webView = findViewById(R.id.webView) ... Read More
Use the String() method in JavaScript to convert to String. You can try to run the following code to learn how to convert { } to String in JavaScript.ExampleLive Demo Convert {} to String var myVal = {}; document.write("String: " + String(myVal));
Use the Boolean() method in JavaScript to convert to Boolean. You can try to run the following code to learn how to convert [ ] to Boolean in JavaScript.ExampleLive Demo Convert [] to Boolean var myVal = []; document.write("Boolean: " + Boolean(myVal));
To set the shape of the border of the top-right corner in JavaScript, use the borderTopRightRadius property. Set border radius using this property.ExampleYou can try to run the following code to learn how to set the shape of the top-right border with JavaScript.Live Demo #box { border: thick solid gray; width: 300px; height: 200px } Demo Text Change top right border radius function display() { document.getElementById("box").style.borderTopRightRadius = "20px"; }
The altkey property is used to show whether SHIFT key is pressed or not when key event was triggered.ExampleYou can try to run the following code to learn how to implement shiftKey property in JavaScript. Press any key function funcShiftKey(event) { var val = document.getElementById("res"); if (event.shiftKey) { val.innerHTML = "SHIFT key: Pressed"; } else { val.innerHTML = "SHIFT key: NOT Pressed"; } }
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP